+ 2

Can someone help me with this im stuck with this code

#include <iostream> using namespace std; int main() { int num; //need help! cout<<"Shop will give you discount if you shop \n 5000 plus = 10 % \n 10000 plus = 15% \n 20000 plus = 20%"; cout<<endl; cout<<"Enter your shopped value :"; cin>>num;cout<<num;cout<<endl; if (num>5000){cout<<"with discounted : ";cout<<num*.9;cout<<endl;} if (num>9999 && num < 20000){cout<<"with discounted value :";cout<<num*.85;cout<<endl;} if (num>=20000){cout<<"with discounted value ";cout<<num*.8;cout<<endl;} else{cout<<"youre not valid for the discount";} return 0; } /*hi guess im beginner can anyone help me with code. The program i tried to make is if someone shop from any store n if he/she shop more than 5000 then store will give 10%discount if 10000 then 15% n 20000 then 20% And i want it to just show the discout value but the program shows all the discounted values*/

12th Jun 2020, 1:39 PM
Ateeb Elahi
Ateeb Elahi - avatar
4 Answers
+ 2
Ateeb Elahi you write if (num>5000) But it is not if (num>5000 && num<10000) so if i input 12000 your code will output 10% and 15%
12th Jun 2020, 1:44 PM
Petr
+ 1
It worked but it displayed "you are not valid for the discount" at the end how to remove that? And why doesnt the program just show me 15% if value is more than 10000, it shows 10% with it too. Still confused Y_Y btw thanks :))
12th Jun 2020, 6:25 PM
Ateeb Elahi
Ateeb Elahi - avatar
+ 1
Ohh Get it now aww THANK YOU SO MUCH <3
12th Jun 2020, 6:58 PM
Ateeb Elahi
Ateeb Elahi - avatar