simple calculations not working in if else statements

Good morning folks. Taking a c++ in college and i ran into an issue where a simply calculation is not correctly giving the answers. not exactly sure where i am wrong, and any help in finding my error would be appreciated. Thanks.
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
# include<iostream>
# include<iomanip.h>
int main()
{

double discbill;
int amt;
double disc;
disc=.10 * amt;
discbill=amt - disc;
cout<<setprecision(2);
cout<<setiosflags(ios::fixed|ios::showpoint);
cout<<"enter amount sold: ";
cin>>amt;
if (amt <= 200)
{
cout<<"the bill is : "<<amt<<'\n';
}
else
{
 amt=discbill;
 cout<<"the discounted bill is : " <<discbill<<'\n';
}

return 0;
}//end main 


The sequence in which the actions are carried out is wrong.

At lines 9 and 10, the calculations are performed.
Then after that, at lines 13 and 14 you get the input from the user.

That needs to be swapped around, so that the first thing which is done is to get the input from the user, and after that, carry out the calculations.
thank a lot for the feedback chervil. I appreciate it.
Topic archived. No new replies allowed.