My countdown will not work...Please help! //Price is Right clock game #include <
ID: 3558225 • Letter: M
Question
My countdown will not work...Please help!
//Price is Right clock game
#include <iostream>
#include <cmath>
#include "graph1.h"
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
//Variable Declaration
int current_time = 0;
int random_number = 0;
int start_time = 0;
int no_secs = 30;
int diff = 0;
int pic_no=0;
int prize= 0;
int guess =0;
char again;
//Display Graphics window
displayGraphics();
//Get current time
current_time = (int)time(0);
srand(current_time);
do
{
pic_no= rand()% 9 + 1;
start_time = time(0);
do
{
//Get the current time
current_time = time(0);
diff = start_time-current_time;
gout << setPos(155,375) <<"Time Remaining: " <<(no_secs-diff) << endg;
switch(pic_no)
{
case (1):
prize = rand()%600 + 200;
displayBMP("chair.bmp",155,90);
gout<<setPos(155,345)<<"Chair"<<endg;
break;
case (2):
prize = rand()%600 + 200;
displayBMP("couch.bmp",155,90);
gout<<setPos(155,345)<<"Couch"<<endg;
break;
case (3):
prize = rand()%600 + 200;
displayBMP("dodgers.bmp",155,90);
gout<<setPos(155,345)<<"Dodgers"<<endg;
break;
case (4):
prize = rand()%600 + 200;
displayBMP("freezer.bmp",155,90);
gout<<setPos(155,345)<<"Freezer"<<endg;
break;
case (5):
prize = rand()%600 + 200;
displayBMP("jukebox.bmp",155,90);
gout<<setPos(155,345)<<"Jukebox"<<endg;
break;
case (6):
prize = rand()%600 + 200;
displayBMP("lawnmowers.bmp",155,90);
gout<<setPos(155,345)<<"Lawnmower"<<endg;
break;
case (7):
prize = rand()%600 + 200;
displayBMP("piano.bmp",155,90);
gout<<setPos(155,345)<<"Piano"<<endg;
break;
case (8):
prize = rand()%600 + 200;
displayBMP("pooltable.bmp",155,90);
gout<<setPos(155,345)<<"Pooltable"<<endg;
break;
case (9):
prize = rand()%600 + 200;
displayBMP("powerTools.bmp",155,90);
gout<<setPos(155,345)<<"Power Tools"<<endg;
break;
case (10):
prize = rand()%600 + 200;
displayBMP("recliner.bmp",155,90);
gout<<setPos(155,345)<<"Recliner"<<endg;
break;
}
cout<<"Enter value for prize: ";
cin>>guess;
if(guess<prize)
{
gout<<setPos(155,360)<<"HIGHER"<<endg;
}
else if(guess>prize)
{
gout<<setPos(155,360)<<"LOWER"<<endg;
}
else if(guess==prize)
{
gout<<setPos(155,360)<<"!!!!!!YOU WIN!!!!!!"<<endg;
}
}while(diff<no_secs);
cout <<"Do you want to play again?";
cin>>again;
}while(again=='Y'|| again=='y');
return 0;
}
Explanation / Answer
Don't put them in brackets.
put them like this
case 1:
case 2:
etc.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.