All pastes #369403 Raw Edit

Mine

public text v1 · immutable
#369403 ·published 2007-02-23 20:35 UTC
rendered paste body
//pay calculator with variable verification
//max levental

#include <cstdlib>
#include <iostream>
#include <iomanip>
using namespace std;

int main(int argc, char *argv[])
{
    //variable declaration
    int Hours(0), z(0);
    string line;
    char Name[25];
    double Rate(0), Pay(0), OTPay(0);
    cout << "Please enter your name: ";
    cin.getline(Name,20);
    
    cout << "\nPlease enter your rate of pay: $";
    cin >> Rate;
    
    //rate variable verification
    while ( Rate < 0)
    {
       cout << "\nDo you really want to pay me???\nTry again!!!";   
       cout << "\nPlease enter rate: ";  
       cin >> Rate; 
    }      
    
    cout << "\nPlease enter how many hours you've worked: ";
    cin >> Hours;
   
    //hours variable verification   
    while ( Hours < 0)
    {
       cout << "\nThere's no such thing as negative time worked!!!";   
       cout << "\nPlease enter how many hours you've worked: ";  
       cin >> Hours; 
    }      
    //regular pay calculation
    Pay = Hours*Rate;
    //otpay calculation
    if ( Hours > 40 )
       OTPay = 1.5 * ( Hours - 40 ) * Rate;
    
    system("CLS");
    
    //counts the length of the user's name, used later
    line = Name;   
    z = line.length();
    cout << "\n\n";
    cout <<  setw(10) << " " << Name << "'s Pay Summary" <<  endl;
    cout <<  setw(10) << " " ;
    
    //draws border under header that is the length of the user's name plus
    // length of other header characters
    for ( int k=0 ; k<z+14 ; k++ )
        cout << "+"; 
        
    //output, summary of pay
    cout << fixed << setprecision(2);
    cout << "\n\nHours worked  : " << setw(10) << Hours;
    cout << "\nRate of pay   :$" << setw(10) << Rate;
    cout << "\nRegular pay   :$" << setw(10) << Pay;
    cout << "\nOvertime pay  :$" << setw(10) << OTPay;
    cout << "\nTotal pay     :$" << setw(10) << (OTPay + Pay);
    
    cout << endl << endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}