Need someone to Review my project

Am I doing everything right for this project?
Is there anything else I need to do for it???

This is the prompt:
As you probably know, cellular phone plans typically give users a fixed al- lowance of minutes and texts, then charge for every minute or text beyond the allowances. You will write a C++ program that takes the number of overage minutes and overage texts, and outputs a subtotal, tax, and total bill for the user.

You can assume the user ’s billing plan works as follows:


• the base monthly rate is $39.99

• each overage minute costs $0.05

• each overage text costs $0.07

• the tax rate is 7.75%


Fill in all the fields between square brackets (e.g. [Due Date]) with the appropriate information. This code should build without any errors.

You need to add code to perform the following steps:


• Ask the user for the number of overage minutes.

• Ask the user for the number of overage texts.

• Calculate and print the user ’s subtotal, using the following formula: Subtotal = 39.99+((minutes over) * .05) + ((texts over)* .07)
• Calculate and print the user ’s sales tax, using the following formula: Sales Tax = (Subtotal) × .0775
• Calculate and print the user ’s total bill, using the following formula: Total = (Subtotal) + (Sales Tax)

You can assume that the user will never enter a negative number. You may treat the dollar amounts as dollars stored as floating point numbers.


Sample input and output

The following are examples of correct input and output:

M i n u t e s o v e r : 0
T e x t s o v e r : 0
S u b t o t a l : 3 9 . 9 9
Tax : 3 . 0 9 9 2 3
T o t a l : 4 3 . 0 8 9 2


M i n u t e s o v e r : 6
T e x t s o v e r : 0
S u b t o t a l : 4 0 . 2 9
Tax : 3 . 1 2 2 4 8
T o t a l : 4 3 . 4 1 2 5


M i n u t e s o v e r : 3
T e x t s o v e r : 1 1
S u b t o t a l : 4 0 . 9 1
Tax : 3 . 1 7 0 5 3
T o t a l : 4 4 . 0 8 0 5



SO FAR I HAVE THIS:

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
#include <iostream> 
using namespace std; 
int main() 
{
	string username; 
	double monthlyRate = 39.99;
	double overageMinute = 0.00;
	double overageText = 0.00;
	double taxRate = 0.0775; 
	double salesTax = 0; 
	double subtotal = 0; 
	double Total = 0; 

	cout << "How many minutes are you over the monthly? " << endl; 
	cin >> overageMinute; 

	cout << "How many texts are you over for this month? " << endl; 
	cin >> overageText; 

	subtotal = monthlyRate + ((overageMinute*.05) + (overageText*.07)); 

	salesTax = (subtotal)*taxRate; 

	Total = (subtotal)+(salesTax);


	system("pause");
	return 0;
}

Last edited on
You still need to print out the totals?

Maybe not important since this is a short program, but one thing to consider would be making the overage rates a constant variable and using the variable name in the calculations instead of .05 and .07. I try to avoid hardcoding numbers that might be subject to change - that way if they do change, I just update the number in the constant variable declaration and don't have to search through the program to update individual values.
What do you mean print out the totals?
The assignment you posted asks you to calculate and print? You've calculated, but I don't see any cout to the screen with the results.


• Calculate and print the user ’s subtotal, using the following formula: Subtotal = 39.99+((minutes over) * .05) + ((texts over)* .07)
• Calculate and print the user ’s sales tax, using the following formula: Sales Tax = (Subtotal) × .0775
• Calculate and print the user ’s total bill, using the following formula: Total = (Subtotal) + (Sales Tax)

S u b t o t a l : 3 9 . 9 9
Tax : 3 . 0 9 9 2 3
T o t a l : 4 3 . 0 8 9 2
Last edited on
I'm not sure exactly how to do that, I thought I already did it by doing the total = and subtotal =
You did the calculations but that just assigned the totals to the variables. You still need to print out the content of the variables, like you printed out the message to prompt the user to enter their numbers.

for example
cout << "Minutes Over: " << overageminute << endl;
I'm not really sure what to do after I write the calculations down.
Is this how I should do it???: cout << "What is the subtotal?" << endl;
cin >> subtotal;


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
// CPSC 120 
// Project #1
// Due February 27, 2014

#include <iostream> 
using namespace std; 
int main() 
{
	string username; 
	double monthlyRate = 39.99;
	double overageMinute = 0.00;
	double overageText = 0.00;
	double taxRate = 0.0775; 
	double salesTax = 0; 
	double subtotal = 0; 
	double Total = 0; 

	cout << "How many minutes are you over the monthly? " << endl; 
	cin >> overageMinute; 

	cout << "How many texts are you over for this month? " << endl; 
	cin >> overageText; 

	subtotal = monthlyRate + ((overageMinute*.05) + (overageText*.07)); 

	salesTax = (subtotal)*taxRate; 

	Total = (subtotal)+(salesTax);

	cout << "What is the subtotal?" << endl; 
	cin >> subtotal;

	system("pause");
	return 0;
}
Is this how I should do it???: cout << "What is the subtotal?" << endl;
cin >> subtotal;


No - cin will prompt the user to enter the answer you calculated. You don't want to do that.
Sorry, I'm a beginner to programming.
I understand partly, so does this mean I use a different variable after cin >> __ . I don't really understand what variable to use?
Did I do the first part right or is that wrong too?
I think I got it for subtotal, so I ran it and it gave me 39.99

1
2
 
cout << "The user's subtotal is " << subtotal << endl; 
I think I'm done, is this correct?

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
// CPSC 120 
// Project #1
// Due February 27, 2014

#include <iostream> 
using namespace std; 
int main() 
{
	string username; 
	double monthlyRate = 39.99;
	double overageMinute = 0.00;
	double overageText = 0.00;
	double taxRate = 0.0775; 
	double salesTax = 0; 
	double subtotal = 0; 
	double Total = 0; 

	cout << "How many minutes are you over the monthly? " << endl; 
	cin >> overageMinute; 

	cout << "How many texts are you over for this month? " << endl; 
	cin >> overageText; 

	subtotal = monthlyRate + ((overageMinute*.05) + (overageText*.07)); 

	salesTax = (subtotal)*taxRate; 

	Total = (subtotal)+(salesTax);

	cout << "The user's subtotal is " << subtotal << endl; 

	cout << "The user's sales tax is " << salesTax << endl; 

	cout << "The user's total is " << Total << endl; 

	system("pause");
	return 0;
}
You got it. Looks like they want Minutes Over and Texts Over as well.

M i n u t e s o v e r : 0
T e x t s o v e r : 0
S u b t o t a l : 3 9 . 9 9
Tax : 3 . 0 9 9 2 3
T o t a l : 4 3 . 0 8 9 2
Ya, when I debugged it. I did get all 5.
Thanks for helping me out.
You're welcome :)
Topic archived. No new replies allowed.