Part 1.
The program should display a menu with the following options:
Welcome to FastFreight Company.
You can select option from 1-3.
1. Add Freight Order
2. Display Freight Orders
3. Exit the system
The program should ask the user to select the option and then act as follows:
Selected Option Action
1 Call the function addFreightOrder and then display the menu to choose again.
2 Call the function, displayOrders and then display the menu to choose again.
3 Exit the program
Any other number Display an error and then display the menu to choose.
Part 2
Write a function to calculate the shipping charges.
It should accept distance and weight, as arguments. Distance and weight can be decimal numbers.
Input Validation:
Invalid Input Error Code
Values of 0 or less for the weight of the
package
-1
Weight of the package more than 20kg -2
Distance less than 8 miles -3
Distance more than 5000 miles -4
Function should use the following rates to calculate the charges:
Weight of Package (in Kilograms) Rate per mile
2 kg or less $0.50
Over 2 kg but not more than 6 kg $0.60
Over 6 kg but not more than 10 kg $0.80
Over 10 kg but not more than 20
kg
$1.10
Once the function is called with required arguments it should return the error code or the charges
accordingly.
2.addFreightOrder:
This function should ask user for a distance to be shipped and the weight of the parcel. Then call the function calculateFreightCharge to calculate the freight charges accordingly.
If the user enters valid inputs, then the function should generate a Freight ID as follows.
Use the first 4 digits on your student ID as the first Freight ID. Increment it by 1 for next freight.
Then add the details of the freight (Freight ID, FreightCharge and FreightStatus Code as ’W’ ) in to a file named freightData.txt. This txt file can be created in the same folder where you have to program stored.
Refer the file freightSampleData.txt to understand the required format for your output file.
If the user enters an invalid data, then the function should display an appropriate error messages. In such instance function should not add any data to freightData.txt file.
3. displayOrders:
This function should display all the freight order details stored in the file freightData.txt. If the file does not exist it should display appropriate error message.
It's amazing how many of these homework requests are appearing. If you can't even start the homework then change careers. Clearly it is not the right choice for ya.
as far as i know I asked for help not an idiots opinion
and you have no idea what my career is so if you cant help dont bother wasting your time to write a stupid pointless comment thank you
#include <iostream>
usingnamespace std;
int Show_Menu () {
int Selection;
// Do all the pretty printing stuff
cout << ":-> ";
cin >> Selection;
return Selection;
}
void AFO () {
}
void DFO () {
}
int main () {
while ( int Selection = Show_Menu () != 3 ) {
switch ( Selection ) {
case 1 : AFO ();
break;
case 2 : DFO ();
break;
default: cout << "Error";
// Tell operator it was an invalid selection
}
}
return 0;
}
With this example I could proclaim, heh, how come my menu doesn't work and there would probably be lots of people on here that would point out the problem with line 20. The point is, if you want help, show at least a little effort.