Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I WANT TO CLEAR THE SCREEN AFTER THE INPUT FROM THE USER AND THEN KEEP ADDINF SCORE AND KEEP GOING FOR EXAMPLE IN THE PIC

I WANT TO CLEAR THE SCREEN AFTER THE INPUT FROM THE USER AND THEN KEEP ADDINF SCORE AND KEEP GOING FOR EXAMPLE IN THE PIC AFTER I INPUT THE KEY IT WILL DISPLAY ANOTHER ARRAY IN RANDOM BUT I WANT ONLY ONE OUT AND MAKE THE STAR KEEP CHANGING. PLEASE HELP I AM USING XCODE C++ PLEASE

image text in transcribed

#include

#include

#include

#include

#include

using namespace std;

int main() {

char option;

int score = 0;

cout

cout

cout

cout

cout

cout

cin >> option;

if (option == 'K' || option == 'k'){

cout

cout

cout

cout

cout

cin >> option;

}

if (option =='L' || option =='l'){

cout

cout

cout

cin >> option;

}

if (option == 'y' || option == 'Y'){

cout

cout

cout

cout

cout

cout

cin >> option;

}

if (option =='L' || option =='l'){

cout

cout

cout

cin >> option;

}

if (option == 'y' || option == 'Y'){

cout

cout

cout

cout

cout

cout

cin >> option;

}

if (option == 'K' || option == 'k'){

cout

cout

cout

cout

cout

cin >> option;

}

if (option == 'y' || option == 'Y'){

cout

cout

cout

cout

cout

cout

cin >> option;

}

if (option == 'K' || option == 'k'){

cout

cout

cout

cout

cout

cin >> option;

}

if (option =='L' || option =='l'){

cout

cout

cout

cin >> option;

}

if (option == 'y' || option == 'Y'){

cout

cout

cout

cout

cout

cout

cin >> option;

}

if (option == 'P' || option == 'p'){

cout

cout

}

if (option =='p' || option =='P'){

char myArray[2][2]={{'O','O'},{'O','*'}};

char choice;

while(true) {

srand(time(NULL));

int x, y;

char temp;

for (int i=0;i

for (int j=0;j

x = rand() % 2;

y = rand() % 2;

temp = myArray[i][j];

myArray[i][j] = myArray[x][y];

myArray[x][y] = temp;

}

}

cout

for (int i=0;i

for (int j=0;j

{

cout

}

cout

}

cout

cin >> choice;

if ((choice == 'Q' && myArray[0][0] == '*') || (choice == 'W' && myArray[0][1] == '*') || (choice == 'A' && myArray[1][0] == '*') || (choice == 'S' && myArray[1][1] == '*')) {

score += 1;

}

if ((choice != 'Q' && myArray[0][0] == '*') || (choice != 'W' && myArray[0][1] == '*') || (choice != 'A' && myArray[1][0] == '*') || (choice != 'S' && myArray[1][1] == '*')) {

cout

break;

}

if (score ==20){

cout

cout

cout

break;

}

cout

cout

}

cout

cout

usleep(5000000);

if ( score ==20){

char myArray[3][3]={{'O','O','O'},{'O','O','*'},{'O','O','O'}};

char choice;

while(true) {

srand(time(NULL));

int x, y;

char temp;

for (int i=0;i

for (int j=0;j

x = rand() % 3;

y = rand() % 3;

temp = myArray[i][j];

myArray[i][j] = myArray[x][y];

myArray[x][y] = temp;

}

}

cout

for (int i=0;i

for (int j=0;j

{

cout

}

cout

}

cout

cin >> choice;

if ((choice =='Q' && myArray[0][0] == '*') ||(choice == 'A' && myArray[1][0] == '*') || (choice == 'W' && myArray[0][1] == '*') || (choice == 'S' && myArray[1][1] == '*') || (choice == 'E' && myArray[0][2] == '*') || (choice == 'D' && myArray[1][2] == '*') || (choice == 'C' && myArray[2][2] == '*') || (choice == 'Z' && myArray[2][0] == '*') || (choice == 'X' && myArray[2][1] == '*')){

score+=1;

}

if((choice != 'Q' && myArray[0][0] == '*') || (choice != 'A' && myArray[1][0] == '*') || (choice != 'W' && myArray[0][1] == '*') || (choice != 'S' && myArray[1][1] == '*') || (choice != 'E' && myArray[0][2] == '*') || (choice != 'D' && myArray[1][2] == '*') || (choice != 'C' && myArray[2][2] == '*') || (choice != 'Z' && myArray[2][0] == '*') || (choice != 'X' && myArray[2][1] == '*')) {

cout

break;

}

if (score ==40){

cout

cout

break;

}

cout

cout

}

cout

cout

usleep(5000000);

if ( score ==40){

char myArray[4][4]={{'O','O','O','O'},{'O','O','*','O'},{'O','O','O','O'},{'O','O','O','O'}};

char choice;

while(true) {

srand(time(NULL));

int x, y;

char temp;

for (int i=0;i

for (int j=0;j

x = rand() % 4;

y = rand() % 4;

temp = myArray[i][j];

myArray[i][j] = myArray[x][y];

myArray[x][y] = temp;

}

}

cout

for (int i=0;i

for (int j=0;j

{

cout

}

cout

}

cout

cin >> choice;

if((choice == 'Q' && myArray [1][0]== '*') || (choice == 'W' && myArray [1][1]== '*')|| (choice == 'A' && myArray [2][0]== '*') || (choice == 'S' && myArray [2][1]== '*') || (choice == 'E' && myArray [1][2]== '*') || (choice =='D' && myArray [2][2]== '*') || (choice == 'C' && myArray [3][2]== '*') || (choice == 'Z' && myArray [3][0]== '*') || (choice == 'X' && myArray [3][1]== '*') || (choice =='V' && myArray [3][3]== '*') || (choice =='F' && myArray [2][3]== '*') || (choice == 'R' && myArray [1][3]== '*') || (choice == '1' && myArray [0][0]== '*') || (choice == '2' && myArray [0][1]== '*') || (choice == '3' && myArray [0][2]== '*') || (choice == '4' && myArray [0][3]== '*')){

score+=1;

}

if((choice != 'Q' && myArray [1][0]== '*') || (choice != 'W' && myArray [1][1]== '*') || (choice != 'A' && myArray [2][0]== '*') || (choice != 'S' && myArray [2][1]== '*') || (choice != 'E' && myArray [1][2]== '*') || (choice !='D' && myArray [2][2]== '*') || (choice != 'C' && myArray [3][2]== '*') || (choice != 'Z' && myArray [3][0]== '*') || (choice != 'X' && myArray [3][1]== '*') || (choice =='V' && myArray [3][3]== '*') || (choice !='F' && myArray [2][3]== '*') || (choice != 'R' && myArray [1][3]== '*') || (choice != '1' && myArray [0][0]== '*') || (choice != '2' && myArray [0][1]== '*') || (choice != '3' && myArray [0][2]== '*') || (choice != '4' && myArray [0][3]== '*')){

cout

break;

}

if (score ==60){

cout

break;

}

cout

cout

}

cout

cout

}

}

}

return 0;

}

Welcome to whack-A-Mole game Press K for controls: Press P to play the game: Press L for direction: : P Game starts in 10 sec Be sure to have the cap lock on 0 * Whack a mole: S Your SCORE IS: 1/20: The hitting ratio is:5 0 * Whack a mole: S Your SCORE IS: 2/20: The hitting ratio is:10 * 0 Whack a mole: Program ended with exit code: 9 Welcome to whack-A-Mole game Press K for controls: Press P to play the game: Press L for direction: : P Game starts in 10 sec Be sure to have the cap lock on 0 * Whack a mole: S Your SCORE IS: 1/20: The hitting ratio is:5 0 * Whack a mole: S Your SCORE IS: 2/20: The hitting ratio is:10 * 0 Whack a mole: Program ended with exit code: 9

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions