Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Your Task You are going to write a program that inputs the selection of a dessert, and how many fellow students shared it . Your
Your Task
You are going to write a program that inputs the selection of a dessert, and how many fellow students shared it
Your program will compute the total sugar for each. If you exceed the Ministry's daily maximum sugary intake
which is grams of sugar you will get detention.
Sample Run
The following is a sample run of the program. The user's input is printed in blue. The data outputted from your
calculations is printed in green. You dont have to make the text that color in your program.
Please feel free to change the wording of the text. Also, please feel free to change the menu items. Make
something fun.... or change the theme altogether.
Pumpkin Pasty Pie : grams of sugar
Butterbeer Ice Cream : grams of sugar
Bucket of Sugar Pops : grams of sugar
Treacle Tart : grams of sugar
What did you all eat?
How many shared eating it
That's grams each!
You have eaten too much sugar!
You now have detention with an official from the Enthusiastic Promotion of
Student Health & the Ridiculously Overzealous Regulation of Sugary Intake!
Get the choice
:
Informational text
Here is a second run where the student tried to lie to the magically enchanted plates.
Pumpkin Pasty Pie : grams of sugar
Butterbeer Ice Cream : grams of sugar
Bucket of Sugar Pops : grams of sugar
Treacle Tart : grams of sugar
What did you all eat?
How many shared eating it
How many shared eating it
How many shared eating it
That's grams!
You have eaten too much sugar! You now have detention with an official from
the Enthusiastic Promotion of Student Health & the Ridiculously Overzealous
Regulation of Sugary Intake!
Here are some students that shared the dessert with quite a few classmates. They didn't get detention.
Pumpkin Pasty Pie : grams of sugar
Butterbeer Ice Cream : grams of sugar
Bucket of Sugar Pops : grams of sugar
Treacle Tart : grams of sugar
What did you all eat?
How many shared eating it
That's grams each!
You have done well! The Department of the Enthusiastic Promotion of Student
Health & the Ridiculously Overzealous Regulation of Sugary Intake is pleased.
:
Input Validation
:
Requirements
You must think of a solution on your own. The requirements are as follows:
You can use either a Switch or Table to get the user's selection.
Have at least desserts. You are welcome to change the ones used in
the example.
Input the user's selection as an integer.
Input the number of students who shared the dessert assume every
student took an equal share. So if it was grams, and people ate
it you ate grams.
Output how much sugar each student has each.
Write an IfElse statement that tells them if they got detention or not.
Hints
Start off by getting the basic math to work. Afterwards, work in the input validation loop.
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.
If you get caught in an infinite loop. You can cancel your program by holding the ControlC keys.
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
This activity may only be submitted in Intel Format.
Using AT&T format will result in a zero. Any work from a prior semester will receive a zero.
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