Utilities: Programming Assignment # 1
Utilities: Programming Assignment # 1
Programming Assignment # 1
By
Timothy Goodwin
Test Case Input Values Date & Time Actual Output Result
Number
1 500,500,r 2/16 18:55 25,53,26.5,104.5 Pass
2 500,500,c 2/16 18:56 25,53,26.5,104.5 Fail
3 500,500,i 2/16 18:56 25,53,26.5,104.5 Fail
4 500,500,i 2/18 9:20 100,50,35,185 Pass
Appendix B:
//Timothy Goodwin Utilities Program Program Assignment 1 Csc 2100 Spring 2011
#include <iostream>
#include <iomanip>
int main ()
int min;
min = 1000;
int max;
max = 9999;
int number;
double kwh;
double units;
//kilowatt surcharge
double kwhsur;
//sewer charge
double scharge;
//water charge
double wcharge;
//electric charge
double echarge;
//total charges
double tcharges;
//variable to change char category into a string assignment with full names I.E. Residential, Commercial,and
Industrial
string cat;
string Residential,Commercial,Industrial;
//category is input r, R, c, C, i, I
char category;
//category possibilities
char r,R,c,C,i,I;
cout << "Please enter a 4 digit account number and press <Enter>" << endl;
cin>> number;
//data type for account name cin name is account name entry
cout <<"Please enter an account name <= 25 characters, and press <Enter>. Any characters in excess of 25 will be
discarded" << endl;
cout << "enter a service category: enter r (or R) for residential, c (or C) for commercial, or I (or I) for industrial and
the <Enter>" << endl;
//entry of category and if statement to make sure r is chosen if input is not r,R,c,C,i,I
if (category != 'r' && category != 'R' && category != 'c' && category != 'C' && category != 'i' && category !=
'I')
{
category = 'r';
else
if (kwh < 0)
echarge = 2.00;
if (kwh >1000)
kwhsur= 5.00;
else
kwhsur= 0;
if (units < 0)
wcharge = 2.00;
//sewer charge
//total charges
cat = "Residential";
else if
if (kwh < 0)
echarge = 10.00;
if (kwh >1500)
{
kwhsur= 10.00;
else
kwhsur= 0;
if (units < 0)
wcharge = 2.00;
//sewer charge
//total charges
cat = "Commercial";
{
if (kwh <= 2500)
else if
if (kwh < 0)
echarge = 100.00;
if (kwh >1500)
kwhsur= 10.00;
else
kwhsur= 0;
if (units < 0)
wcharge = 50.00;
}
//sewer charge
//total charges
cat = "Industrial";
cout << setw (78) << "COOKEVILLE UTILITY DISTRICT" << endl << endl << endl;
else
cout << "the number was not in the specified range" << endl;
cout << "Account Name: "<< name << endl << endl << endl << endl;
cout << "Electric Consumption = " << kwh << setw (93) << "Electric Charge: $" << echarge << setw (85) << endl;
//Electric surcharge
cout << setw (120) << "Surcharge $" << kwhsur << endl << endl << endl;
//Sewer charge
cout << setw (120) <<" Sewer Charge: $" << scharge << endl;
//Total charges
cout << setw (120) <<"Total Charge: $" << tcharges << endl;
cout << setw (20) << " ************************************** Done Processing Utilitly Bill
************************************************" << endl;
return 0;