Answered step by step
Verified Expert Solution
Link Copied!

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 200 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.
1. Pumpkin Pasty Pie : 520 grams of sugar
2. Butterbeer Ice Cream : 650 grams of sugar
3. Bucket of Sugar Pops : 1605 grams of sugar
4. Treacle Tart : 1004 grams of sugar
What did you all eat?
3
How many shared eating it?
4
That's 401 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
1605-: 4=401
Informational text
3
Here is a second run where the student tried to lie to the magically enchanted plates.
1. Pumpkin Pasty Pie : 520 grams of sugar
2. Butterbeer Ice Cream : 650 grams of sugar
3. Bucket of Sugar Pops : 1605 grams of sugar
4. Treacle Tart : 1004 grams of sugar
What did you all eat?
1
How many shared eating it?
0
How many shared eating it?
-1
How many shared eating it?
2
That's 260 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.
1. Pumpkin Pasty Pie : 520 grams of sugar
2. Butterbeer Ice Cream : 650 grams of sugar
3. Bucket of Sugar Pops : 1605 grams of sugar
4. Treacle Tart : 1004 grams of sugar
What did you all eat?
2
How many shared eating it?
5
That's 130 grams each!
You have done well! The Department of the Enthusiastic Promotion of Student
Health & the Ridiculously Overzealous Regulation of Sugary Intake is pleased.
650-: 5=130
Input Validation
520-: 2=260
4
Requirements
You must think of a solution on your own. The requirements are as follows:
1. You can use either a Switch or Table to get the user's selection.
2. Have at least 4 desserts. You are welcome to change the ones used in
the example.
3. Input the user's selection as an integer.
4. Input the number of students who shared the dessert assume every
student took an equal share. So, if it was 100 grams, and 5 people ate
it, you ate 100/5=20 grams.
5. Output how much sugar each student has each.
6. Write an If-Else 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 Control+C keys.
5
Creating Your Program
1. Write your program with nano.
nano lab6.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 lab6.o lab6.asm
3. To link your program, type the following:
ld -o a.out lab6.o csc35.o
4. To run your program, type the following:
./a.out
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 lab6.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

More Books

Students also viewed these Databases questions