Answered step by step
Verified Expert Solution
Question
1 Approved Answer
this is assembly code please make sure to follow every single introduction please make sure to write the assembly code yourself, no plegerism please. The
this is assembly code please make sure to follow every single introduction please make sure to write the assembly code yourself, no plegerism please.
The Sorting Hat's Algorithm
While the Sorting Hat seems mysterious and powerful, it follows a basic nested If Statement. Well, this isn't really true, but it's your instructor's attempt to turn it into a programming assignment.
So for this assignment, let's assume that it simply senses the answers to a few questions and then puts the student into the correct house hopefully The logic is as follows:
Examples
This is the output from one possible solution. Your solution doesn't have to look exactly like the example below. But, make sure to fulfill all the requirements. Input is displayed in blue.
Welcome to Hogwarts
The Sorting Hat is being placed upon your head.
Do you desire to have Power or To be creative?
Do you find contentment in Knowledge or Friends & community?
Ravenclaw Welcome to Hogwarts!
The Sorting Hat is being placed upon your head.
Do you desire to have Power or To be creative?
Do you wish to do this for Yourself or Others?
GryEEindor
Input Validation
So what happens if the user enters an invalid number? The Sorting Hat is going to ask the question again. So
your program must repeat the question if they enter an invalid value. This is actually quite easy to implement,
once you understand the logic.
Welcome to Hogwarts
The Sorting Hat is being placed upon your head.
Do you desire to have Power or To be creative?
Do you desire to have Power or To be creative?
Do you desire to have Power or To be creative?
Question asked
Do you wish to do this for Yourself or Others?
again, and again
Slytherin! The Sorting Hat is being placed upon your head.
Repeat thequestion.
Don't restart.
Do you desire to have Power or To be creative?
Don't restart.
Do you find contentment in Knowledge or Friends & community?
Do you find contentment in Knowledge or Friends & community?
Hufflepuff!
Have Fun!
You don't have to use the four houses from Harry Potter. Create your own four categories. Naturally, the
questions will be different, but the overall approach is the same. The following are some example categories.
What class in a role player game are you?
What should you have for dinner?
What meme do you most resemble?
Which SpongeBob character are you?
Which Rick and Morty alien are you?
What kind of pet should you get species, breed, etc...
What political philosophy are you?
What music you should listen to
etc...Tips
Like all labs, build it in pieces. First get a single IfStatement to work. Then, you can work on to more
detailed ones.
All labels must be unique. Choose your names well.
Assembly doesn't have blocks... so don't think in those terms. Your program will be structured far
differently from programs in Java.
Requirements
Now work on each of the requirements below one at a time. You will turn in the final program, but incremental
design is best for labs. You must think of a solution on your own.
The requirements are as follows:
Display text explaining the theme of your program. You don't have create the Hogwarts one that I usec. Use
your imagination!
Input each choice with prompts You must input a character. Any lab that uses ScanChar will receive a
zero.
If the user enters an invalid number, repeat the question!
Implement the logic in the flowchart above. Use nested IfStatements.
Display the output for all four possibilities.
Your Task
So for your assignment, you get to create a program to recreate the Sorting Hat.
You will ask questions and the user will respond with a character. Based on their answers, you will print which
house they will be put into.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started