I am hoping someone can help guide me in the right direction.
I have a project for class that I am working on and I could use some help. The project guidelines are below as well as my code thus far.
I have gotten this far with it but am having trouble specifically on accounting for the maximum hours in a month, and in Package B where it talks about charging $1 per 3-hour unit over 50 hours. Currently, my code is charging $1 per hour over 50 hours which is incorrect.
Thanks in advance for any assistance.
DROP LEAP YEAR REQUIREMENT
ASSUME FEB 672 hrs
An Internet service provider has three different subscription packages for its customers:
Package A: For $12 per month with 10 hours of access provided.
Additional hours are $2.00 per hour for the next
20 hours of usage. Then the charges are $1.00 for
each additional hour thereafter.
Assume usage is recorded in one-hour increments,
i.e., a 25-minute session is recorded as one hour.
Package B: For $18 per month with 20 hours of access provided.
Additional hours are $1.00 per hour for the next
30 hours of usage. Then the charges are $1.00 for
each additional 3-hour unit of usage thereafter,
i.e., 1 or 2 hour(s) of aggregated usage would be
charged $1.00.
Package C: For $25 per month with 200 hours access is provided.
Additonal $10 for the next 250 hours and an additional
$15 for usage over 450 hours.
Write a program that calculates a customer’s monthly charges.
Must account for the maximum hours in a month.
Validate all input.
//Program 2 ISP Packages
#include <iostream>
using namespace std;
void main()
{
int pkg;
cout<<"Enter pkg: ";
cin>>pkg;
if( pkg==1 || pkg==2 || pkg==3)
{
int hrs;
cout<<"Enter hrs: ";
cin>>hrs;
if( hrs>= 0 && hrs<=720 )
{
int chg;
switch(pkg)
{
case 1:
chg = 12 + ( (hrs>10) ? (hrs-10)*2 : 0 );
break;
case 2:
{
chg = 18 + ( (hrs>20 && hrs<=50) ? (hrs-20)*1 : 0 ); //Case 2 is working except for the $1
chg = 18 + ( (hrs>50) ? 30 + (hrs - 50)*1 : (hrs-20)*1); //for each 3-hour unit. I'm charging
break; //$1 per hour. Must fix!
}
case 3:
{
if (hrs<=200)
{
chg=25;
}
else if (hrs>200 && hrs<=450)
{
chg=35;
}
else if (hrs>450)
{
chg=50;
}
break;
}
default:
break;
}
cout<<"charges: "<<chg<<endl;
}
else
{
cout<<"Invalid hrs"<<endl;
}
}
else
{
cout<<"Invalid pkg"<<endl;
}
}//main