การกำหนดเงื่อนไขโดยกำหนดวันเป็นหมายเลข
#include <iostream>
#include <conio.h>
int main()
{
int x; char name[10];
cout<<"Enter the name: ";
cin>>name;
cout<<"What is the first day of weeks?
Please select the number 1-7.
1.Monday 2.Tuesday 3.Wednesday 4.Thursday 5.Friday 6.Saturday 7.Sunday ";
cin>>x;
switch(x)
{
case 1: cout<<"Monday";
break; case 2: cout<<"Tuesday";
break; case 3: cout<<"Wednesday";
break; case 4: cout<<"Thursday";
break; case 5: cout<<"Friday";
break; case 6: cout<<"Saturday";
break; default: cout<<"Sunday";
break;
}
if(x==1)
{
cout<<" Total score = 5"<< x;
}
else if(x==2)
{
cout<<" Total score = 0"<<x;
}
else if(x==3)
{
cout<<" Total score = 0"<<x;
}
else if(x==4)
{
cout<<" Total score = 0"<<x;
}
else if(x==5)
{
cout<<" Total score = 0"<<x;
}
else if(x==6)
{
cout<<" Total score = 0"<<x;
}
else if(x==7)
{
cout<<" Total score = 0"<<x;
}
getch( );
}
#include <conio.h>
int main()
{
int x; char name[10];
cout<<"Enter the name: ";
cin>>name;
cout<<"What is the first day of weeks?
Please select the number 1-7.
1.Monday 2.Tuesday 3.Wednesday 4.Thursday 5.Friday 6.Saturday 7.Sunday ";
cin>>x;
switch(x)
{
case 1: cout<<"Monday";
break; case 2: cout<<"Tuesday";
break; case 3: cout<<"Wednesday";
break; case 4: cout<<"Thursday";
break; case 5: cout<<"Friday";
break; case 6: cout<<"Saturday";
break; default: cout<<"Sunday";
break;
}
if(x==1)
{
cout<<" Total score = 5"<< x;
}
else if(x==2)
{
cout<<" Total score = 0"<<x;
}
else if(x==3)
{
cout<<" Total score = 0"<<x;
}
else if(x==4)
{
cout<<" Total score = 0"<<x;
}
else if(x==5)
{
cout<<" Total score = 0"<<x;
}
else if(x==6)
{
cout<<" Total score = 0"<<x;
}
else if(x==7)
{
cout<<" Total score = 0"<<x;
}
getch( );
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น