doing loops with Ifs..can't figure out why it wont add them up

basically im asking the user to enter numbers. IF the numbers are greater than 100, give them a discount. This part i got working fine, however i now need to add a loop and then add up the total of the discounts and print it out.
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
# include<iostream.h>
# include<iomanip.h>
int main()
{
int i=0;
double total=0;
double discBill;
int amt;
double disc;
for(i=0;i<10;i++)
	{
	cout<<setprecision(2);
	cout<<setiosflags(ios::fixed|ios::showpoint);
	cout<<"\nenter amount sold: ";
	cin>>amt;
	disc=.10 * amt;
	discBill=amt - disc;
	if (amt < 200)
	{
	cout<<"\nthe bill is : "<<amt<<'\n';
	}
	else
	{
 	discBill++;
 	cout<<"\nthe discounted bill is : " <<discBill<<'\n';
	}
	total=discBill*amt;
	cout<<"\nthe total discount for everyone is : "<<discBill<<'\n';
	}

return 0;
}//end main 



enter amount sold: 500

the discounted bill is : 451.00

the total discount for everyone is : 451.00

enter amount sold: 300

the discounted bill is : 271.00

the total discount for everyone is : 271.00

enter amount sold:

what am i doing wrong (i know my math is off) thanks!



Can't you just add each value up as you go in the current loop you have?

I don't know what you think is wrong, your program is...odd, and it doesn't even remotely match what you seem to be asking for.
well i'm lost as to what you are saying. basically at the end of the program i want it to print out the total amount of discount from the total sales.
closed account (Dy7SLyTq)
first on lines 2 and 3 remove the .h and put a c in front of the the header names. second, on line 16, it has to be 0.10 not just .10. this is because the ., when not used in math, is used for classes
Topic archived. No new replies allowed.