All pastes #917755 Raw Edit

Mine

public text v1 · immutable
#917755 ·published 2008-02-25 17:32 UTC
rendered paste body
#include <iostream>
using namespace std;

int main(){
    char d1;
    char d2;
    int hour;
    int length;
    double charge = 0.00;
    int numericalDay;
  
    cout << "Long distance charge calculator\n";
    cout << "Enter the day your call will be made\n(Mo Tu We Th Fr Sa Su): ";
    cin >> d1 >> d2;
    cout << "Enter the hour in which your call was made. Use 24 hour notation.\n(0-23; 0 = 12:00 AM 23 = 11:00PM): ";
    cin >> hour;
    cout << "Enter the number of minutes your call lasted: ";
    cin >> length;
    numericalDay = d1*d2;
    
    //Strings aren't allowed in switch statements, and adding the numerical values of the characters comes out with wed and thurs identical, so i multiplied them.
    switch(numericalDay){
        case 8547:            
        case 9828:
        case 8787:
        case 8736:
        case 7980:
            switch(hour){
                case 0:
                case 1:
                case 2:
                case 3:
                case 4:
                case 5:
                case 6:
                case 7:
                case 18:
                case 19:
                case 20:
                case 21:
                case 22:
                case 23:
                    charge = .25;
                    break;
                case 8:
                case 9:
                case 10:
                case 11:
                case 12:
                case 13:
                case 14:
                case 15:
                case 16:
                case 17:
                    charge = .40;
                    break;              
                default:
                    cout << "There is something wrong with your hour.\n";
                    break;
            }
            break;
        case 8051:
        case 9711:
            charge = .15;
            break;
        default: 
            cout << "There is something wrong with your day.\n";
            break;
            
    }
    
    cout << "The cost of your call is $" << charge * length << ".\n"; 

    cout << "Press enter to continue...";
    fflush(stdin);
    cin.get();
}  

//Long distance charge calculator
//Enter the day your call will be made
//(Mo Tu We Th Fr Sa Su): Fr
//Enter the hour in which your call was made. Use 24 hour notation.
//(0-23; 0 = 12:00 AM 23 = 11:00PM): 7
//Enter the number of minutes your call lasted: 15
//The cost of your call is $3.75.
//Press enter to continue...