Question #39109

Speedy Overnight Shipping uses four shipping methods: air, truck, rail, and hand delivery.
Write C++ program that allows the user to type in a shipping method code: ‘a’, ‘t’, ‘r’, or ‘h’.
Have the program display the shipping rate according to the following table:
Method Rate
a 14.95
t 10.25
r 8.75
h 25.99
1

Expert's answer

2014-02-14T11:51:37-0500

Answer on Question#39109 - Programming – C++


#include <iostream>
#include <stdlib.h>
using namespace std;
#define A 14.95
#define T 10.25
#define R 8.75
#define H 25.99
int main()
{
    char c;
    cout << "Input shipping method (a,t,r,h): ";
    c = cin.get();
    cout << "The shipping rate is: ";
    switch (c)
    {
        case 'A':
        case 'a':
            cout << A;
            break;
        case 't':
        case 'T':
            cout << T;
            break;
        case 'r':
        case 'R':
            cout << R;
            break;
        case 'h':
        case 'H':
            cout << H;
            break;
        default:
            cout << "you've inputted wrong shipping method";
            break;
    }
    cout << "\n";
    system("PAUSE");
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS