Professional Documents
Culture Documents
Mapua Institute of Technology: Machine Project CS10L
Mapua Institute of Technology: Machine Project CS10L
Machine Project
CS10L
BASIC COMPUTER
PROGRAMMING FOR
ENGINEERING
Machine Program Statement
Singing Me
Functions
int main()
{
srand((unsigned)time(0));
int
randnum,a,rpt,c,y,score1,score2,score3,n1,n2,n3,n4,n5,count;
char
name[10]="Player",ans,rptorext,hiscore1[10]="Player",hiscore2[10
]="Player",hiscore3[10]="Player";
score1=0;
score2=0;
score3=0;
rpt=1;
while(rpt==1)
{
count=0;
n1=0;
n2=0;
n3=0;
n4=0;
n5=0;
y=0;
cout<<" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n";
cout<<" ^ TTTTT HH HH EEEEE ^\n";
cout<<" ^ T HH HH EE ^\n";
cout<<" ^ T HHHHH EEE ^\n";
cout<<" ^ T HH HH EE ^\n";
cout<<" ^ T HH HH EEEEE ^\n";
cout<<" ^ ^\n";
cout<<" ^ SSSSS II NN NN GGGGG II NN NN GGGGG ^\n";
cout<<" ^ SS II NNN NN GG II NNN NN GG ^\n";
cout<<" ^ S II NN NNN GG GG II NN NNN GG GG ^\n";
cout<<" ^ SS II NN NN GG G II NN NN GG G ^\n";
cout<<" ^ SSSSS II NN NN GGGGG II NN NN GGGGG ^\n";
cout<<" ^ ^\n";
cout<<" ^ MM MM EEEEE ^\n";
cout<<" ^ MMM MMM EE ^\n";
cout<<" ^ MMMMMMM EEE ^\n";
cout<<" ^ MM M MM EE ^\n";
cout<<" ^ MM MM EEEEE ^\n";
cout<<" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n";
cout<<"\n\t\t\t[1]Start Game\n";
cout<<"\t\t\t[2]Instructions\n";
cout<<"\t\t\t[3]Top Score\n";
cout<<"\t\t\t[4]Exit\n";
cout<<"\t\t\tChoose your number of choice: ";
cin>>a;
cin.ignore();
system("cls");
if(a==1)
{
cout<<"Enter Your First Name: ";
cin>>name;
cout<<"\n\nWelcome "<<name<<" to The Singing Me!!!";
cin.ignore();
cin.ignore();
system("cls");
cout<<"\tGENRE\n";
cout<<"[1]Rock Songs\n";
cout<<"[2]Pop Songs\n";
cout<<"Choose The Genre You Want To Play: ";
cin>>c;
cin.ignore();
system("cls");
if(c==1)
{
for(int i=0; count<5; i++)
{
randnum=(rand()%10)+1;
if(randnum!=n1&&randnum!=n2&&randnum!=n3&&randnum!=n4&&randnum!=n5)
{
switch(randnum)
{
case 1:
cout<<"Level 1\n\n";
cout<<"\t\t\tROCK SONGS\n\n";
cout<<"\t\tSong Title: Sugar We're Going Down\n\t\tArtist: Fall Out
Boy\n\n";
cout<<"\tDrop a heart, _______ a name We're always sleeping in,
and sleeping\n";
cout<<"for the wrong team\n\n";
cout<<"\t\ta. break b. make\n\n";
cout<<"Your answer: ";
cin>>ans;
if(ans=='a')
{
y++;
}
else
{
count=5;
}
count++;
break;
}
if(i==0)
{
n1=randnum;
}
if(i==1)
{
n2=randnum;
}
if(i==2)
{
n3=randnum;
}
if(i==3)
{
n4=randnum;
}
if(i==4)
{
n5=randnum;
}
}
system("cls");
}
if(y==5)
{
count=0;
n1=0;
n2=0;
n3=0;
n4=0;
n5=0;
if(y==45)
{
cout<<"\t\tCongratulations "<<name<<"!!\n\n";
cout<<"\t\t\tYou are the Singing Me Champion!\n\n";
cout<<"You got a total of "<<y<<" pt/pts.\n\n";
cout<<"Press [y] to try again\n";
cout<<"Press [n] to exit the game\n\n";
cout<<"[Y/N]:";
cin>>rptorext;
cin.ignore();
system("cls");
}
else
{
cout<<"\t\tGAME OVER!\n\t Please try again!\n\n";
cout<<"You got a total of "<<y<<" pt/pts.\n\n";
cout<<"Press [y] to try again\n";
cout<<"Press [n] to exit the game\n\n";
cout<<"[Y/N]:";
cin>>rptorext;
cin.ignore();
system("cls");
if(rptorext=='n')
{
rpt=0;
}
}
if(c<0||c>2)
{
cout<<"Invalid Choice!";
cin.ignore();
system("cls");
}
}
if(a==2)
{
cout<<"\t\t\t\t**INSTRUCTIONS**\n\n";
cout<<"*Start the game\n";
cout<<"*Enter your name\n";
cout<<"*Choose genre, each genre has 3 levels\n";
cout<<"*Answer the missing lyrics in the given song\n";
cout<<"*Answer 5 correct questions to proceed to the next level\n";
cout<<"*Scores are posted after the game\n";
cout<<"*Option to continue or exit the game\n";
cin.ignore();
system("cls");
}
if(y<=score2&&y>score3)
{
score3=y;
strcpy(hiscore3,name);
}
if(y<=score1&&y>score2)
{
score3=score2;
score2=y;
strcpy(hiscore3,hiscore2);
strcpy(hiscore2,name);
}
if(y>score1)
{
score3=score2;
score2=score1;
score1=y;
strcpy(hiscore3,hiscore2);
strcpy(hiscore2,hiscore1);
strcpy(hiscore1,name);
}
if(a==3)
{
cout<<"\t\t\t\tTOP SCORES\n\n";
cout<<"1."<<hiscore1<<"\t"<<score1<<" pt./pts.\n";
cout<<"2."<<hiscore2<<"\t"<<score2<<" pt./pts.\n";
cout<<"3."<<hiscore3<<"\t"<<score3<<" pt./pts.\n";
cin.ignore();
system("cls");
}
if(a==4)
{
rpt=0;
}
if(a<0||a>4)
{
cout<<"Invalid Choice!";
cin.ignore();
system("cls");
}
}
return 0;
}
THE END