Am I going at this all wrong?

So here is what I need to do...

Write a program which accepts a total purchase price and computes any discount.
Purchase Price Discount %
< 1000 0%
1000 -2499.99 1.5%
2500 - 3999.99 2%
4000 -7499.99 2.5%
7500+ 2.75%

A sample run with user input highlighted appears below.
Enter total price? 3500.00
A discount of 2.00% saving $70.00 means you pay only $3430.00!
Press any key followed by enter to continue...


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
// 2C.cpp : Defines the entry point for the console application.
// 4/10/17

#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

void Pause()
{
	string junk;
	cout << "Press any to continue ... ";
	cin.ignore();
	getline(cin, junk);
}

int main()
{

//declare vairables.
float PRICE ;
float newPrice;
float discount;
int amount;

cout << "Enter total price ? ";
		cin >> amount;

		
			if (PRICE <= 999)
				newPrice = PRICE;
			else if (amount >= 1000 && amount <= 2499.99)
				newPrice = PRICE - (PRICE * 0.15 = )

			else if (amount >= 2500 && amount <= 2500)
				newPrice = PRICE - (PRICE * 0.2)

			else if (amount >= 4000 && amount <= 7499.99)
				newPrice = PRICE - (PRICE * 0.25)

			else if (amount >= 7500)
				newPrice = PRICE - (PRICE * 0.275)

			else (PRICE = newprice)
		

	cout << "A discount of " << discount << " means you pay only ";
	cout << newPrice << "!" << endl;
	
	//freeze screen
	Pause();
	return 0;
}
Last edited on
Line 32: Don;t you mean to check amount?

Lines 32-46: PRICE is an uninitialized variable.

Line 37: Check your conditional. Your second comparison is wrong.

Line 46: Under what condition would this line ever get executed? If it were to execute, you would be setting PRICE to an uninitialized variable.

Line 49: You print discount, but you never calculated it. discount is an uninitialized variable.
Last edited on
I had only 30 minutes to make it so I took a guess. I have no idea what you said. way over my head lol
Topic archived. No new replies allowed.