Hi all. I am fairly new to programming. so I need a little help. I was given this assignment today and can't seem to figure out what I am doing wrong. Here is the assignment and my code is below it. I have three different files. Was hoping someone could look over it and give me some direction. Thanks.
An Internet service provider has three different subscription packages for its customers:
Package A: For $15 per month with 50 hours of access provided.
Additional hours are $2.00 per hour over 50 hours.
Assume usage is recorded in one-hour increments,
Package B: For $20 per month with 100 hours of access provided.
Additional hours are $1.50 per hour over 100 hours.
Package C: For $25 per month with 150 hours access is provided.
Additional hours are $1.00 per hour over 150 hours
Write a program that calculates a customer’s monthly charges.
Implement with the following functions in a separate functions.cpp file:
getPackage
validPackage
getHours
validHours
calculatePkg_A
calculatePkg_B
calculatePkg_C
calculateCharges
showBill
Validate all input.
Demonstrate valid and invalid cases.
Show console dialog. It must be readable.
Here is what I have so far.
1 2 3 4 5 6 7 8 9 10 11
|
//functions.h
char getValidPkg();
char getValidHrs();
char calculatePkg_A();
char calculatePkg_B();
char calculatePkg_C();
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
#include <iostream>
using namespace std;
#include "Header.h"
int main()
{
char pkg;
pkg = getValidPkg();
cout<<"Pkg: "<<pkg<<endl;
int hrs;
hrs = getValidHrs();
cout<<"Hrs: "<<hrs<<endl;
}//endmain
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#include <iostream>
using namespace std;
bool isValidPkg( char p ) //checkpkg
{
return (p>='A' && p<='C') || (p>='a' && p<='c');
}
char getValidPkg() //getpkg
{
char p=0;
do
{
cout<<"Enter pkg: ";
cin>>p;
}
while( !isValidPkg(p) );
return p;
}
bool isValidHrs( int h ) //checkhrs
{
return (h>=0 && h<=720);
}
char getValidHrs() //gethrs
{
int h;
do
{
cout<<"Enter hours: ";
cin>>h;
}
while( !isValidHrs(h) );
return h;
}
|