PLEASE HELP!!!

I am working on this assignment and I have half of it completed, I am struggling with writing code and plan to get some help with it but if someone could help me with what is due tomorrow that would be great!

You combine phase 1 and phase 2 in the same program, and you will only have one int main(). After the inputs and calculations are done for Phase 1, your program will move immediately to phase 2 by printing “*** Coupons ***” and then asking for input. YOUR PROGRAM MUST COMPILE as is. If you have two int main() functions, your program will not compile and you will get a 0 for the lab.
Overview: Write a program that computes the amount of your next purchase, then computes the final purchase amount given each coupon, and finally prints which coupon provides the better benefit. 
 
Inputs: Your program will take the following inputs: 

1. The amount of the two coupons (i.e., the percentage amount of coupon 1 and the dollar amount of coupon 2) as doubles. 

2. The quantity and price for three separate items. For each item you will enter a quantity as an integer and a price as a double. 

3. The sales tax percentage as a double. 

Outputs: 
1. The total amount of the purchase 
2. The amount of the purchase with coupon 1 3. The amount of the purchase with coupon 2 4. The coupon that provides the better benefit.
a. If both coupons have the same benefit, output “Both coupons have the same benefit”

You will need to calculate the total of all items and then subtract the coupon’s benefit. After that is completed, you will need to add the sales tax to get the final result. 
 
Here’s a sample interaction with the program for Phase 2 (user input in blue):
*** Coupons ***
Please enter a percentage amount for coupon 1: 5.5
Please enter a dollar amount for coupon 2: 15
Please enter the quantity and price for your first item: 8 2.25 Please enter the quantity and price for your second item: 10 1.25 Please enter the quantity and price for your third item: 15 19.99 Please enter the sales tax as a percentage: 6.5
Total before coupon = 351.82 Total with coupon 1 = 332.47 Total with coupon 2 = 335.85 Use coupon 1



this is what I have thus far:
#include <iostream>

using namespace std;

int main( )

{

int month, day, year;
int adjustment, adjustedMonth, adjustedYear, dayOfWeek;

cout << "***Homework***/n" << endl;
cout << "Please enter a date (month day year) : " ;
cin>> month >> day >> year;

adjustment = (14 - month) /12;
adjustedYear = year - adjustment;
adjustedMonth= month + 12*adjustment-2;
dayOfWeek= (day+adjustedYear+ (adjustedYear / 4) -(adjustedYear/ 100)+(adjustedYear/ 400)+(31*adjustedMonth)/12) %7;

cout<< "Your day of birth: " << dayOfWeek ;

cout<< "***coupons***/n" << endl;



return 0;
}
So basically what you have so far is this?
1
2
3
4
5
6
7
#include	<iostream>
using namespace	std;
int	main()
{
	cout << "***coupons***/n" << endl;
	return	0;
}


The code to figure out what day of the week it was doesn't seem relevant to the question you posted.

I want to help you, but if this is really all you have, then you're not even making an attempt at this. All you did was literally output coupons.

We're more than willing to help you here, but we wont flat out do your homework for you. Make an actual attempt and when you get stuck, post again and i'll help you out.
Last edited on
Sorry I misread the assignment and didn't realize the questions were not related we are supposed to put them on the same file.

I am having trouble even beginning the problem. How should I begin to think about creating the code.
Next time don't wait until the last second to try to get a project done.

Please study more, because it's only going to get harder.

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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <iostream>
#include <iomanip> //Include so we can use fixed and setprecision(2) to round our dollar amounts to the hundredths place (for cents)
using namespace	std;
int	main()
{
	int month, day, year;
	int adjustment, adjustedMonth, adjustedYear, dayOfWeek;

	cout << "***Homework***/n" << endl;
	cout << "Please enter a date (month day year) : ";
	cin >> month >> day >> year;

	adjustment = (14 - month) / 12;
	adjustedYear = year - adjustment;
	adjustedMonth = month + 12 * adjustment - 2;
	dayOfWeek = (day + adjustedYear + (adjustedYear / 4) - (adjustedYear / 100) + (adjustedYear / 400) + (31 * adjustedMonth) / 12) % 7;

	cout << "Your day of birth: " << dayOfWeek;


	float Coupon1Percentage = 0.0;
	float Coupon2DollarAmount = 0.0;
	int Item1Quantity = 0;
	int Item2Quantity = 0;
	int Item3Quantity = 0;
	float Item1Price = 0.0;
	float Item2Price = 0.0;
	float Item3Price = 0.0;
	float SalesTax = 0.0;
	float TotalBeforeCoupon = 0.0;
	float TotalAfterCoupon1 = 0.0;
	float TotalAfterCoupon2 = 0.0;

	cout << "***Coupons***/n" << endl;
	cout << "Please enter a percentage amount for coupon 1: ";
	cin >> Coupon1Percentage; //Get Coupon 1 Percentage
	cout << "Please enter a dollar amount for coupon 2: ";
	cin >> Coupon2DollarAmount; //Get Coupon 2 Dollar Amount
	cout << "Please enter the quantity and price for your first item: ";
	cin >> Item1Quantity; //Get Quantity
	cin >> Item1Price; //Get price
	cout << "Please enter the quantity and price for your second item: ";
	cin >> Item2Quantity; //Get Quantity
	cin >> Item2Price; //Get price
	cout << "Please enter the quantity and price for your third item: ";
	cin >> Item3Quantity; //Get Quantity
	cin >> Item3Price; //Get price
	cout << "Please enter your sales tax as a percentage: ";
	cin >> SalesTax; //Get Sales Tax

	//Calculate Total (without Sales Tax)
	TotalBeforeCoupon = (Item1Quantity*Item1Price) + (Item2Quantity*Item2Price) + (Item3Quantity*Item3Price);

	TotalAfterCoupon1 = TotalBeforeCoupon * ((100 - Coupon1Percentage) / 100);//Calculate price before sales tax
	TotalAfterCoupon2 = TotalBeforeCoupon - Coupon2DollarAmount; //Calculate price before sales tax
	TotalBeforeCoupon *= (1 + (SalesTax / 100)); //Calculate price after sales tax
	TotalAfterCoupon1 *= ((100 + SalesTax) / 100); //Calculate price after sales tax
	TotalAfterCoupon2 *= ((100 + SalesTax) / 100); //Calculate price after sales tax
	

	cout << fixed << setprecision(2) << "Total before coupon = " << TotalBeforeCoupon << endl;
	cout << "Total with coupon 1 = " << TotalAfterCoupon1 << endl;
	cout << "Total with coupon 2 = " << TotalAfterCoupon2 << endl;
	if (TotalAfterCoupon1 == TotalAfterCoupon2) //If the totals are the same
	{
		cout << "Both coupons give the same discount." << endl;
	}
	else if (TotalAfterCoupon1 < TotalAfterCoupon2) //else If total after coupon 1 is cheaper
	{
		cout << "Use coupon 1." << endl;
	}
	else //else If total after coupon 2 is cheaper
	{
		cout << "Use coupon 2." << endl;
	}
	return	0;
}
Last edited on
Topic archived. No new replies allowed.