o AT&T; LTE 9:17 AM 44% bbhosted cuny edu FedEx has hired you to write a little
ID: 3565251 • Letter: O
Question
o AT&T; LTE 9:17 AM 44% bbhosted cuny edu FedEx has hired you to write a little utility program to help out shipping locations ll help you packages. without dgital (Intermet) connection to outside world. For example, North Pole office do not have connection to the central FedEx system orthe Internet. letter. Yes, Fedex wants to open up an office in Cost this delivery?18.99 North Pole:-D Search Rail CNy State Now, for these offices FedEx needs little utility program to help their staff keep track of packages. Here are the features of the program: Search Nail Ch Cesti de you want to de? 2 a Koj 1- Create New Mail: Allows us to letter. enter a package to the system. We need two pieces of information from the user: a) the state where the package is going (2 letter abbreviation) and b)the cost of the delivery. ihat are larger value A30 2- Search Mail (by State): Takes a state name (two letter abbreviation) from Chy cost user and goes through al the packages What do you, want to 4 entered into the system and displays for todaya those that are going to that state. paekasen toda in $16.98 B0 Search Mail (by Cost): Takes a Search Rail Ch Cost dollar amount from user. Then displays What de yes went to do? all packages in the system with cost larger than the amount entered. 1100- Exit: Exits the program (duh!!) 130 Comments and Indentations. You can assume there are most 1000 packages per day for specifying the sian of your amays). Mail and Package is the same thing! don't get confused. Refer to screenshot displayed above.Explanation / Answer
#include<iostream>
#include<string.h>
using namespace std;
struct package{
char destination[3];
double cost;
};
typedef struct package package;
package arr[1000];
int count = 0;
void insert(){
cout << "Destination State (two letter, no space) : ";
cin >> arr[count].destination;
cout << "Cost of this delivery : ";
cin >> arr[count].cost;
count++;
cout << endl;
}
void searchByState(){
char temp[3];
cout << "Enter state you want to see (two letter, no space) : ";
cin >> temp;
cout << "Here are the packages to " << temp << ": ";
for(int i=0; i<count; i++){
if(strcmp(arr[i].destination, temp) == 0){
cout << "Package to " << temp << " for $" << arr[i].cost << endl;
}
}
cout << endl;
}
void searchByCost(){
double val;
cout << "Enter minimum package price : ";
cin >> val;
cout << "Here are the packages that are larger in value than " << val << ": ";
for(int i=0; i<count; i++){
if(arr[i].cost > val){
cout << "Package to " << arr[i].destination << " for $" << arr[i].cost << endl;
}
}
cout << endl;
}
void grandReport(){
int grandTotal = 0;
cout << "Here are all the packages for today : ";
for(int i=0; i<count; i++){
cout << "Package to " << arr[i].destination << " for $" << arr[i].cost << endl;
grandTotal += arr[i].cost;
}
cout << "Total cost for all packages today so far is $" << grandTotal << ". ";
cout << endl;
}
int main(){
int choice;
int flag = 0;
cout << "************************************************* ";
cout << "Welcome to FedEx in the middle of nowhere. |-> ";
cout << "This tool will help you keep track of packages. ";
cout << "*************************************************** ";
do{
cout << "1- Create New Mail ";
cout << "2- Search Mail(by State) ";
cout << "3- Search Mail (by Cost) ";
cout << "4- Grand Report ";
cout << "0- Exit ";
cout << "What do you want to do? : ";
cin >> choice;
switch(choice){
case 1 :
insert();
break;
case 2 :
searchByState();
break;
case 3 :
searchByCost();
break;
case 4 :
grandReport();
break;
case 0 :
cout << "Press any key to continue ... ........ ";
flag = 1;
break;
default :
cout << "Enter a valid input and try again ";
cout << endl;
}
}while(!flag);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.