All pastes #179785 Raw Edit

Stuff

public cpp v1 · immutable
#179785 ·published 2006-09-22 14:33 UTC
rendered paste body
// Header files to include for data manipulation#include <iostream>#include <iomanip>#include <string>using namespace std;// Regular plan constantsconst double regFee = 10.00;const int regIncluded = 50;const double regOverage = 0.20;// Premium plan constantsconst double premFee = 25.00;const int premDayIncl = 75;const double premDayOverage = 0.10;const int premNightIncl = 100;const double premNightOverage = 0.05;int main(){	// Declare character variables	char service;	// Declare integer variables	int account, totalMin, dayMin, nightMin;	// Declare double variables	double billTotal;        // blah blah strings	// Perform formatting for output statements	cout << showpoint << fixed << setprecision(2);	// Prompt user for account number	cout << "Please enter your account number: ";	// Get input	cin >> account;	cout << endl;	// Prompt user for type of service	cout << "What type of service do you have?\n";	cout << "Enter [ R ] for Regular or [ P ] for Premium: ";	// Get input	cin >> service;	// If statement to deal with the bill for users who are on the	// "Regular" plan	if (service == "r" || service == "R") {		cout << "Please input the number of minutes you have used this month: ";		cin >> totalMin;		cout << endl << endl;				// If they've used more than their 50 allowed minutes, determine bill cost		// With overages included		if (totalMin > regIncluded)			billTotal = regFee + ((totalMin - regIncluded) * regOverage);		// Else, they only only owe the standard rate for Regular service.		else			billTotal = regFee;	// If statement to handle bill for users who are on the	// "Premium" plan	} else if (service == "p" || service == "P") { 		// Get number of day time minutes		cout << "Please input the number of day time minutes you" 			 << " have used this month: ";				cin >> dayMin;		// Get number of night time minutes		cout << "\nPlease input the number of night time minutes"			 << " you have used this month: ";				cin >> nightMin;		cout << endl << endl;		// Did the user exceed both day and night time minutes?		if (dayMin > premDayIncl && nightMin > premNightIncl)			billTotal = premFee + ((dayMin - premDayIncl) * premDayOverage)			+ ((nightMin - premNightIncl) * premNightOverage);				// Did user exceed day minutes, but not night?		else if (dayMin > premDayIncl && nightMin <= premNightIncl)			billTotal = premFee + ((dayMin - premDayIncl) * premDayOverage);		// Did user exceed night minutes, but not day?		else if (dayMin <= premDayIncl && nightMin > premNightIncl)			billTotal = premFee + ((nightMin - premNightIncl) * premNightOverage);        // Else, they must have went over neither.. and only owe standard		// rate for Premium service.		else 			billTotal = premFee;			} else {                       cout << "Invalid service type!\n\n\n";        // Return 0 to end the program early if invalid service type found.                        return 0;        }			// Output statement with formatting for easy reading	cout << setfill(' ');	cout << "Account #" << setw(20) << "Service Type" << setw(20) << "Minutes Used"		 << setw(14) << "Amount Due" << endl;	cout << "---------------------------------------------------------------------"		 << "-----\n";	cout << account << setw(5) << " " << setw(15) << setw(15) << plan << " ";	// Seperate if statement to determine whether to output premium or regular	// plan minutes to the user.	if (plan == "Premium")		cout << setw(15) << dayMin + nightMin;	else if (plan == "Regular")		cout << setw(15) << totalMin;		cout << setw(15) << " $" << billTotal << endl << endl << endl;	return 0;}