Question: PLEASE WRITE IN C++ Flow Control, File Handling and Arrays: Introduction In this assignment you will write a small C++ program. Your program should compile
PLEASE WRITE IN C++
Flow Control, File Handling and Arrays: Introduction In this assignment you will write a small C++ program. Your program should compile correctly and produce the specified output. Problem Statement
The program will read a file (cityInfo.txt) containing city information. This information includes city id, group, location (x, y) and city name. The cityInfo.txt has the following format:
int char double double string
For example:
107 S 18.30 66.10 San Juan, P.R.
45 H 21.18 157.50 Honolulu, Hawaii
54 K 24.33 81.48 Key West, Fla.
67 M 25.46 80.12 Miami, Fla.
119 T 27.57 82.27 Tampa, Fla.
103 S 29.23 98.33 San Antonio, Tex.
47 H 29.45 95.21 Houston, Tex.
Table 1: Input File Example Where: - Column 1 is the ID A unique integer value. It may not be continuous, - Column 2 is the group an upper-case character [A-Z] - Column 3 is X coordinate, - Column 4 is Y coordinate, - Column 5 is city name. It may include spaces, commas, dots, to indicate state/province and country.
After reading the file the program will display a menu. Using the menu, the user can select to display the cities with ID within a range (e.g., display the city info for all the cities with ID >=6 and ID=0, 0<= max_id. <=minimum(N,1000). N is the number of cities in the input file. (10 points)
4) When option b) is selected, the program asks the user to enter a character. This character (e.g., group_char) must be in the range [A, Z]. (5 points)
Notice: for options a and b, display the city info as in table 1. All the columns are left aligned. Use 6 positions for ID, 8 positions for group, 10 positions with precision 2 for X and Y coordinated, and 30 for the city name.
5) When option c) or d) are selected, the program asks for an integer. If the integers entered for city 1 and city 2 are the same (same id is entered), a message should warn the user and ask to try again. (10 points)
6) If option e) is chosen: a. Determine if city 1 and 2 have been entered. If not, warn the user and display the menu again. This is, if only city 1, or only city 2 are defined, the program cannot compute the distance. (10 points) b. Compute the linear distance and display it on the screen (8-byte fields, with precision 2). You can reuse any of your functions from previous homework assignment or any function written in class or available in your textbook/slides. Avoid copy and paste from google search or anywhere else. (5 points)
7) After any of the options a to e is chosen, the menu should be displayed again (5 points).
8) The program will finish only when option f is chosen (5 points).
9) If any other option is selected (i.e., any option different of a-f), display a message indicating that the option is invalid. (5 points)
Hint: Linear distance between two points (i.e., P1 and P2) with coordinates (x1, y1) and (x2, y2), on a 2D plane: d = sqrt( (x2-x1)^2 + (y2-y1)^2)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
