My program reads what a user wants to buy if its the monitor a,b or c whenever i enter the amount of money it always ends up with money minus the price of the monitor a although i choose monitor b im new with programming i just started literally just a week ago if you may please help me with my problem. I searched all over the net to fix my problem but i just cant find the solution to my problem hope you can help me guys :)
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int a,b,c,num1,e;
char m;
std::cout<<"Which monitor do you want to buy?\na.Monitor1\nb.Monitor2\nc.Monitor3\n";
std::cin>>m;
{
switch (m)
{
case 'a':
std::cout<<"The price of the monitor is 1200\nSpecs:\nDiagonal Screen Size\n15.6 inches\nNative Resolution\n1920 x 1080\nSupported Video Formats\n1080p\n";
break;
case 'b':
std::cout<<"The price of the monitor is 1300\nSpecs:\nDiagonal Screen Size\n24 inches\nNative Resolution\n1920 x 1080\nSupported Video Formats\n1080p\n";
break;
case 'c':
std::cout<<"The price of the monitor is 1500\nSpecs:\nDiagonal Screen Size\n34 inches\nNative Resolution\n3440 x 1440\nSupported Video Formats\n1080p\n";
break;
default:
std::cout<<"Error:\nThe character you mentioned is not available\n";
break;
}
{
std::cout<<"Enter how much money you have\n";
std::cin>>e;
a=1200;
num1=e-a;
b=1300;
num1=e-b;
c=1500;
num1=e-c;
if(e>a)
{
num1=e-a;
std::cout<<"Your change is:\n"<<num1;
}
else if(e>b)
{
num1=e-b;
std::cout<<"Your change is:\n"<<num1;
}
else if(e>c)
{
num1=e-c;
std::cout<<"Your change is:\n"<<num1;
}
}
getch();
}
}
what is ur expectation i mean suppose u have entered a as monitor and amount 1250 then if amount is greater than and less than b and less than then should it do num1=e-a;
std::cout<<"Your change is:\n"<<num1;