You are on page 1of 19

Mapua Institute of Technology

Machine Project
CS10L

BASIC COMPUTER
PROGRAMMING FOR
ENGINEERING
Machine Program Statement

Singing Me

Singing Me is a one player game


wherein, the player should be able to
answer/fill in the missing lyrics of the
song correctly. There are choices from
which one choice is the correct answer.
Objectives

To fill in the missing lyrics of the song


To be able to provide all the correct
answers
To beat the high scores
To be the Singing Me Champion
Data Dictionary

Functions

Function Name Description Return type Parameters

main() This line int, char


corresponds
to the
beginning of
the definition
of the main
function.
Variables
Identifier Name Data type Local to (specify if local to Description
a particular function)
n1,n2,n3,n4,n5 int Stores the random
numbers, which will not
be repeated
rpt int Stores a number that
determines if the program
will repeat or exit
a, c int Stores the number which
is inputted from the
choices given
y int Stores the number of
points gained

score1, score2, score3 int Stores the number of


points for the top score

randnum int Stores the random


number

count int Stores the count of the


number of questions
asked
name[10] char Stores the name of the
player

hiscore1, hiscore2, hiscore3 char Stores the names of the


players in the top scores

ans char Stores the answer of the


player for each question

rptorext Stores the inputted letter


to repeat or exit
Screen Shots
Program listing (code)
#include <cstdlib>
#include <ctime>
#include <iostream>

using namespace std;

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

You might also like