C++ ASSIGNMENT

Hi everyone, need help with this assignment. its due today and will be appreciated if anyone can help me out with these questions.




CPSC 1103 Assignment 1
Problem
A cell phone provider has three different subscription packages for its customers:
Package A: For $9.95 per month 10 hours of access are provided. Additional hours are $2.00 per hour.
Package B: For $14.95 per month 20 hours of access are provided. Additional hours are $1.00 per hour.
Package C: For $19.95 per unlimited access is provided.
Write a program to ask which package the customer has purchased, what month they are using and how many hours were used.
Determine maxHours. Months with 30 days have 720 hours, and months with 31 days have 744 hours. February, with 28 days, has 672 hours.

Month Days Hours
January 31 744
February 28 672
March 31 744
April 30 720
May 31 744
June 31 744
July 31 744
August 30 720
September 31 744
October 31 744
November 30 720
December 31 744

Input validation: Be sure the user only selects package A, B, or C. Also, the number of hours used in a month cannot exceed maxHours (or be less than 0).
Display the charge for the Package chosen.

Display how much money Package A customers would save if they purchased packages B or C;
how much money Package B customers would save if they purchased packages A or C;
and how much Package C customers would save if they purchased packages A or B.
If there would be no savings, no message should be printed.

What to hand in:

Please see the title page for requirements for assignments.
You need the following in a single Word document:
• Source code listing fully documented (comments for purpose, file, programmer, all variable declarations, and major tasks).
• Test runs to show valid and invalid data as well as savings.
• User Guide with Purpose stated for a User, a simple run to illustrate the capability of the program and a section for assumptions and limitations
• A hierarchy chart for example to calculate the area of a rectangle


// Assignment #1
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;

int main()
{
int package
string Name , Month;
double hours;

cout << "Please enter your name " << endl;
cin >> Name ;

cout << "Please enter the letter of the package you choose.\n"
<<" 1 = For $9.95 per month 10 hours of access are provided.\n"
<< " Additional hours are $2.00 per hour.\n"
<< " 2 = For $14.95 per month 20 hours of access are provided.\n"
<< " Additional hours are $1.00 per hour.\n"
<< " 3 = For $19.95 per month unlimited access is provided.\n";
cin >> package ;

if ( package <1 || package > 3)
{
cout << " Error! You cannot choose from package other than A, B or C.\n"
<< " Please run the program again with package either A, B or C .\n";
main();
}

cout << "Enter the month you are using " << endl;
cin >> Month ;

cout << "Enter the number of hours you used " << endl;
cin >> hours ;



/* Months with 30 days (i.e. April, June, September, November ) have 720 hours,
and months with 31 days ( i.e. January, March, May, July, August, October, December ) have 744 hours.
February, with 28 days, has 672 hours.*/

if (hours > 720 && (Month == "April" || Month == "June" || Month == "September"
|| Month == "November" ))
{
cout << "Error!...The hours are not right...There are only 720 hours in the month of " << Month << endl;
cout << " Please run the program again with number of hours less than 720 " << endl;
}

if (hours > 744 && (Month == "January" || Month == "March" || Month == "May"
|| Month == "July" || Month == "August" || Month == "October"
|| Month == "December" ))
{
cout << "Error!...The hours are not right...There are only 744 hours in the month of " << Month << endl;
cout << " Please run the program again with number of hours less than 744 " << endl;
}

if (hours > 672 && (Month == "February" ))
{
cout << "Error!...The hours are not right...There are only 672 hours in the month of " << Month << endl;
cout << " Please run the program again with number of hours less than 672 " << endl;
}

if (hours < 0 && (Month == "January" ||Month == "February" || Month == "March" || Month == "April" || Month == "May"
|| Month == "June" || Month == "July" || Month == "August" || Month == "September" || Month == "October"
|| Month == "November" || Month == "December" ))
{
cout << "Error!...The hours are not right...The hours should be grater than 0 in the month of " << Month << endl;
cout << " Please run the program again with number of hours greater than 0 " << endl;
}



return 0 ;

}

I got this and im not sure if its right. Can someone guide me to the right answer ?!




Last edited on
well, you did the validation but you are missing the cost computation.
notice that no matter what package you chose, you still need to compute the cost of the three.

1
2
3
4
5
6
7
def plan_a(hours):
   basic = 9.95
   hours -= 10
   extra = 0
   if hours > 0:
      extra = ceil(hours)*2
   return basic + extra
Last edited on
Registered users can post here. Sign in or register to post.