Answered step by step
Verified Expert Solution
Link Copied!

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.
3
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 1. Power or 2. To be creative?
2
Do you find contentment in 1. Knowledge or 2. Friends & community?
1
Ravenclaw!
Creativity Power
Seek power
or creativity?
Enjoy
knowledge or
people?
KnowledgePeople
Hufflepuff Ravenclaw Gryffindorr Slytherin
For
yourself or
others?
YourselfOthers
Sorting Hat
4
Welcome to Hogwarts!
The Sorting Hat is being placed upon your head.
Do you desire to have 1. Power or 2. To be creative?
1
Do you wish to do this for 1. Yourself or 2. Others?
2
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 1. Power or 2. To be creative?
3
Do you desire to have 1. Power or 2. To be creative?
-5
Do you desire to have 1. Power or 2. To be creative?
1
Do you wish to do this for 1. Yourself or 2. Others?
1
Slytherin!
Question asked
again, and again
5
Welcome to Hogwarts!
The Sorting Hat is being placed upon your head.
Do you desire to have 1. Power or 2. To be creative?
2
Do you find contentment in 1. Knowledge or 2. Friends & community?
4
Do you find contentment in 1. Knowledge or 2. Friends & community?
2
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.
6
Tips
Like all labs, build it in pieces. First get a single If-Statement 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:
1. Display text explaining the theme of your program. You don't have create the Hogwarts one that I used. Use
your imagination!
2. Input each choice (with prompts). You must input a character. Any lab that uses ScanChar will receive a
zero.
3. If the user enters an invalid number, repeat the question!
4. Implement the logic in the flowchart above. Use nested If-Statements.
5. Display the output for all four possibilities.
7
Creating Your Program
1. Write your program with nano.
nano lab5.asm
2. 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 lab5.o lab5asm
3. To link your program, type the following:
ld -o a.out lab5.o csc35.o
4. To run your program, type the following:
./a.out
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 lab5.asm

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

Expert Performance Indexing In SQL Server

Authors: Jason Strate, Grant Fritchey

2nd Edition

1484211189, 9781484211182

Students also viewed these Databases questions