السلام عليكم ورحمة الله وبركاته
الربامج التالي يطبع السيارة وسعرها ولونها
لكن في جملة cout أريده أن يطبع بدلا من x نوع السيارة وبدلا من y فما الطريق؟
#include<iostream.h>
void main()
{
//y=color
int y;
char x;//x=car
double money;
int want;
//want رغبة المستخدم
cout<<"n Do you want to buy a car (1=Yes,No=0)?";
cin>>want;
if(want==0)
cout<<"n Do not forget us visit againn";
else
{
cout<<"nBMW ****** its price 300.000.00 S.R";
cout<<"nGMC ****** its price 200.000.00 S.R";
cout<<"nHonda ****** its price 70.000.00 S.R";
cout<<"nNissan ****** its price 50.000.00 S.R";
cout<<"nMazda ****** its price 35.000.00 S.R";
cout<<"nHow much cash do you have ?";
cin>>money;
if(money>=30000000)
{
cout<<"n B=BMW";
cout<<"n G=GMC";
cout<<"n H=Honda";
cout<<"n N=Nissan";
cout<<"n M=Mazda";
cout<<"n choose the car model?";
cin>>x;
switch(x)
{
case 'B':
case 'b':cout<<"n (BMW) car ,with(300.000.00 S.R)n";
break;
case 'G':
case 'g':cout<<"n(GMC) car,with(200.000.00 S.R) n";
break;
case 'H':
case 'h':cout<<"n(Honda)car,with(70.000.00 S.R)n";
break;
case 'N':
case 'n':cout<<"n(Nissan)car,with(50.000.00 S.R)n";
break;
case 'M':
case 'm':cout<<"n(Mazda)car,with(35.000.00 S.R)n";
break;
}
cout<<"n1=Red";
cout<<"n2=Black";
cout<<"n3=Blue";
cout<<"n4=White";
cout<<"nEnter your choose(1-4)?";
cin>>y;
switch(y)
{
case 1:cout<<"Redn";
break;
case 2:cout<<"Blackn";
break;
case 3:cout<<"Bluen";
break;
case 4:cout<<"Whiten";
break;
}
cout<<"nyou buy a "<< x <<" "<<",with "<<
"its color is "<<y;
}
else
if(money<=20000000)
{
cout<<"n G=GMC";
cout<<"n H=Honda";
cout<<"n N=Nissan";
cout<<"n M=Mazda";
cout<<"n choose the car model ?";
cin>>x;
switch(x)
{
case 'G':
case 'g':cout<<"n(GMC) car,with(200.000.00 S.R) n";
break;
case 'H':
case 'h':cout<<"n(Honda)car,with(70.000.00 S.R)n";
break;
case 'N':
case 'n':cout<<"n(Nissan)car,with(50.000.00 S.R)n";
break;
case 'M':
case 'm':cout<<"n(Mazda)car,with(35.000.00S.R)n";
break;
}
cout<<"n1=Red";
cout<<"n2=Black";
cout<<"n3=Blue";
cout<<"n4=White";
cout<<"nEnter your choose(1-4)?";
cin>>y;
switch(y)
{
case 1:cout<<"Redn";
break;
case 2:cout<<"Blackn";
break;
case 3:cout<<"Bluen";
break;
case 4:cout<<"Whiten";
break;
}
cout<<"nyou buy a "<<x <<" "<<",with "<<
" its color is "<<y;
}
else
if(money<=7000000)
{
cout<<"n H=Honda";
cout<<"n N=Nissan";
cout<<"n M=Mazda";
cout<<"n choose the car model ?";
cin>>x;
switch(x)
{
case 'H':
case 'h':cout<<"n(Honda)car,with(70.000.00 S.R)n";
break;
case 'N':
case 'n':cout<<"n(Nissan)car,with(50.000.00 S.R)n";
break;
case 'M':
case 'm':cout<<"n(Mazda)car,with(35.000.00S.R)n";
break;
}
cout<<"n1=Red";
cout<<"n2=Black";
cout<<"n3=Blue";
cout<<"n4=White";
cout<<"nEnter your choose(1-4)?";
cin>>y;
switch(y)
{
case 1:cout<<"Redn";
break;
case 2:cout<<"Blackn";
break;
case 3:cout<<"Bluen";
break;
case 4:cout<<"Whiten";
break;
}
cout<<"nyou buy a "<<x<<" "<<",with "<<
" its color is "<<y;
}
else
if(money<=5000000)
{
cout<<"n N=Nissan";
cout<<"n M=Mazda";
cout<<"n choose the car model ?";
cin>>x;
switch(x)
{
case 'N':
case 'n':cout<<"n(Nissan)car,with(50.000.00 S.R)n";
break;
case 'M':
case 'm':cout<<"n(Mazda)car,with(35.000.00S.R)n";
break;
}
cout<<"n1=Red";
cout<<"n2=Black";
cout<<"n3=Blue";
cout<<"n4=White";
cout<<"nEnter your choose(1-4)?";
cin>>y;
switch(y)
{
case 1:cout<<"Redn";
break;
case 2:cout<<"Blackn";
break;
case 3:cout<<"Bluen";
break;
case 4:cout<<"Whiten";
break;
}
cout<<"nyou buy a "<<x <<" "<<",with "<<
" its color is "<<y;
}
else if(money==3500000)
cout<<"n M=Mazda";
cin>>x;
switch(x)
{
case 'M':
case 'm':cout<<"n(Mazda)car,with(35.000.00S.R)n";
break;
}
cout<<"n1=Red";
cout<<"n2=Black";
cout<<"n3=Blue";
cout<<"n4=White";
cout<<"nEnter your choose(1-4)?";
cin>>y;
switch(y)
{
case 1:cout<<"Redn";
break;
case 2:cout<<"Blackn";
break;
case 3:cout<<"Bluen";
break;
case 4:cout<<"Whiten";
break;
}
cout<<"nyou buy a "<<x <<" "<<",with "<<
" its color is "<<y;
}
}
