|
C++ Homework: Cable Company Plans |
|
|
|
Saturday, 16 August 2008 |
|
Read More Articles in: Technology>>>Programming
This Article is written by
This e-mail address is being protected from spam bots, you need JavaScript enabled to view it
Time to post my C++ homework I did. This one is a very basic cable company plan inclusion and exclusion calculation......
//Written by
This e-mail address is being protected from spam bots, you need JavaScript enabled to view it
#include <iostream>
using namespace std;
//Constants of resident and business plans
const double r_process_fee = 4.50, b_process_fee = 15.00;
const double r_service_fee = 20.50, b_service_fee = 75.00;
const double r_channel = 7.50, b_channel = 50.00;
int main(){
//declaration
int accountNumber = 0;
char r_or_b;
int channelNumbers = 0;
int b_connection = 0;//for business rule
double totalAmount = 0;
//Input
cout<<fixed<<showpoint;
cout<<setprecision(2);
cout<<"This program computes a cable bill."<<endl;
cout<<"Ennter your Account Number"<<endl;
cin>>accountNumber;
cout<<"Entr your Customer Type ('r' for Resident, 'b' for Business)"<<endl;
cin>>r_or_b;
switch(r_or_b)
{
case 'r':
//entry
cout<<"Enter the number of premium channels"<<endl;
cin>>channelNumbers;
//Cal.
totalAmount = r_process_fee + r_service_fee + (r_channel * channelNumbers);
//result
cout<<"Account Number: "<<accountNumber<<endl;
cout<<"Total Amount: $"<<totalAmount<<endl;
break;
case 'b':
//entry
cout<<"Enter the number of basic service connections"<<endl; //extra entry for business plan
cin>>b_connection;
cout<<"Enter the number of premium channels"<<endl;
cin>>channelNumbers;
//Cal.
if ( b_connection <= 10)
{
totalAmount = b_process_fee + b_service_fee + ( channelNumbers * b_service_fee );
}
else
{
totalAmount = b_process_fee + b_service_fee + (
(b_connection - 10) * b_service_fee ) + ( channelNumbers *
b_service_fee );
}
//result
cout<<"Account Number: "<<accountNumber<<endl;
cout<<"Total Amount: $"<<totalAmount<<endl;
break;
default:
cout<<"Wrong Customer Type, You must enter eith 'r' or 'b'"<<endl;
break;
}//end of switch
return 0;
}//end of main()
 Tags: Technology Programming C++ Homework Cable Company Plans |
|
Last Updated ( Saturday, 16 August 2008 )
|