Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PROGRAM 6 : Match Game Write a program that reads a match number and then a list of numbers from a user. The program should

PROGRAM 6: Match Game
Write a program that reads a match number and then a list of numbers from a user. The program should end when the number entered exactly equals the match number or exceeds it. Once the game ends, display the total number of positive and negative numbers entered as well as the longest consecutive streak of similarly signed quantities. Shown below is a sample program dialogue.
Shown below are sample program dialogues to help you build your program.
Gimme a goal number: 50
Feed Me: 12
Feed Me: -7
Feed Me: -1
Feed Me: 8
Feed Me: 1
Feed Me: -5
Feed Me: 50
You Hit The Match!
You Fed Me: 4 positive quantities and 3 negative quantities
Longest Positive Streak Of Quantities: 2
Longest Negative Streak Of Quantities: 2
Gimme a goal number: 49
Feed Me: 12
Feed Me: -7
Feed Me: -1
Feed Me: 8
Feed Me: 1
Feed Me: -5
Feed Me: 60
You Missed The Match!
You Fed Me: 4 positive quantities and 3 negative quantities
Longest Positive Streak Of Quantities: 2
Longest Negative Streak Of Quantities: 2
(Hint: This program is pretty complex with many different conditions to keep track of. I would recommend you write it first in C or Visual Basic and then translate your lines of code, one-by-one, into a assembly statements, just like our good friend mr. compiler does)
(Additional Hint: You should not be using high language statements like for, while or repeat loops, as these are not assembly instructions are off limits in this course.)
Without using high level programming such as loops and if statements.
Here is my c code that works but want to convert to HLA assembly
#include
int main(){
int goal, number;
int positiveCount =0, negativeCount =0;
int longestPositiveStreak =0, longestNegativeStreak =0;
int currentPositiveStreak =0, currentNegativeStreak =0;
int hitMatch =0;
printf("Gimme a goal number: ");
scanf("%d", &goal);
while (1){
printf("Feed Me: ");
scanf("%d", &number);
// Check if the game should end
if (number == goal){
hitMatch =1;
break;
} else if (number > goal){
break;
}
// Count positive and negative numbers
if (number >0){
positiveCount++;
currentPositiveStreak++;
currentNegativeStreak =0;
if (currentPositiveStreak > longestPositiveStreak){
longestPositiveStreak = currentPositiveStreak;
}
} else if (number <0){
negativeCount++;
currentNegativeStreak++;
currentPositiveStreak =0;
if (currentNegativeStreak > longestNegativeStreak){
longestNegativeStreak = currentNegativeStreak;
}
} else {
// Reset streaks on zero input
currentPositiveStreak =0;
currentNegativeStreak =0;
}
}
if (hitMatch){
printf("You Hit The Match!
");
} else {
printf("You Missed The Match!
");
}
printf("You Fed Me: %d positive quantities and %d negative quantities
", positiveCount, negativeCount);
printf("Longest Positive Streak Of Quantities: %d
", longestPositiveStreak);
printf("Longest Negative Streak Of Quantities: %d
", longestNegativeStreak);
return 0;
}
Without using high level programming such as loops and if statements.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions

Question

1. Give them prompts, cues, and time to answer.

Answered: 1 week ago

Question

Describe alternative training and development delivery systems.

Answered: 1 week ago

Question

Summarize the learning organization idea as a strategic mind-set.

Answered: 1 week ago