Code:
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
int code = 0;
int charges = 0;
//enter input data
cout << "State code: ";
cin >> code;
cout << "Shipping charges: ";
cin >> charges;
switch (code)
{
case 1:
charges = 25;
break;
case 2:
case 5:
case 6:
charges = 30;
break;
case 3:
case 4:
charges = 40;
break;
default:
cout << "Incorrect state code" << endl;
} //end switch
//display charges
cout << "Charges: " << charges << endl;
return 0;
} //end of main function
It shows no errors on build but when go to enter number it does not display the charges? Have worked and worked on it cannot figure it out would appreciate some help in this matter as quick as possible. I am a newbie and I am really struggling!! same thing with the Net one below!!
#include <iostream>
#include <string>
#include <iomanip>
using std::cout;
using std::cin;
using std::endl;
using std::fixed;
using std::setprecision;
int main()
{
double hours = 0.0;
double rate = 0.0;
double gross = 0.0;
//enter input data
cout << "Hours worked: ";
cin >> hours;
cout << "Pay rate: ";
cin >> rate;
//validate hours
if (hours <= 0.0)
cout << "The hours worked must be greater than 0." << endl;
//validate rate
else if (rate <= 0.0)
cout << "The pay rate must be greater than 0." << endl;
//calculate gross pay
else if (hours <= 40.0)
gross = hours * rate;
else gross = 40.0 * rate + (hours - 40.0) * rate * 1.5;
//end ifs
//display gross pay
cout << fixed << setprecision(2);
cout << "The gross pay for working " << hours << " hours at $"
<< rate << " per hour is $" << gross << endl;
return 0;
} //end of main function
Comment