Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Your Task So , for your assignment, you get to create a program to recreate the Sorting Hat. You will ask questions and the user
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.
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!
Creativity Power
Seek power
or creativity?
Enjoy
knowledge or
people?
KnowledgePeople
Hufflepuff Ravenclaw Gryffindorr Slytherin
For
yourself or
others?
YourselfOthers
Sorting Hat
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?
Gryffindor
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?
Do you wish to do this for Yourself or Others?
Slytherin!
Question asked
again, and again
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?
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...
Repeat the
question.
Don't restart.
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 used. 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.
Creating Your Program
Write your program with nano.
nano labasm
To assemble your program into an object file, type the following. Warning: If you list your asm file directly
after the o it will be destroyed.
as o labo labasm
To link your program, type the following:
ld o aout labo csco
To run your program, type the following:
aout
Submitting Your Lab
Type the following to submit your lab. This will transfer a copy of your lab to me NOTE: You can only submit your
assignment once. Make sure you got it working.
submit labasm
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