Question: 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.)
Withoug 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;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!