Reference no: EM132323612
Programming and Problem Solving Lab Assignment - Selection Structures
Assignment Outcomes - By completing this assignment, students will be able to:
1) Structure programs to include conditional logic.
2) Write code that includes if/else statements.
3) Design programs that leverage switch/case logic.
4) Solve problems of increasing complexity.
Program 1: Back in my Day! Kids who grew up in the late 70s didn't have a lot of options for video games, but they did have "Choose your own Adventure" books. These books were cool and let the reader make meaningful decisions. If they chose choice "A", they would turn to a page of the book and continue their adventure. If they chose choice "B", they would turn to a different page and read a different adventure. Your task is to design (pseudocode) and implement (source code) for a story that has four different outcomes based on two different user inputs. See appendix for checking string equality.
Sample run 1:
It is a dark and stormy night. Do you want to take an umbrella? (Y/N): Y
Good - you have an umbrella.
You start to walk down a path and hear a scream. You realize that the person screaming is YOU because you see a wolf! Do you fight with your umbrella or run? ((F)ight/(R)un): F
You take out your umbrella and jab it into the wolf's paw! It runs away and you live another day.
Sample run 2:
It is a dark and stormy night. Do you want to take an umbrella? (Y/N): Y
Good - you have an umbrella.
You start to walk down a path and hear a scream. You realize that the person screaming is YOU because you see a wolf! Do you fight with your umbrella or run? ((F)ight/(R)un): R
You begin running so fast, the umbrella opens and you fly away like Mary Poppins. You're a little embarrassed, but you see the wolf fading off in the distance.
Sample run 3:
It is a dark and stormy night. Do you want to take an umbrella? (Y/N): N
You decide not to take an umbrella.
You start to walk down a path and hear a scream. You realize that the person screaming is YOU because you see a wolf! Do you fight with your umbrella or run? ((F)ight/(R)un): F
You begin fighting the wolf only to realize you had just eaten a McGrease® meal earlier. You fall dead from rigorous exercise, having had a heart attack.
Sample run 4:
It is a dark and stormy night. Do you want to take an umbrella? (Y/N): N
You decide not to take an umbrella.
You start to walk down a path and hear a scream. You realize that the person screaming is YOU because you see a wolf! Do you fight with your umbrella or run? ((F)ight/(R)un): R
Are you serious? You can't outrun a wolf! The wolf catches you and you are somewhat relieved because you don't have to worry about that Calculus exam...
Program 2: Your friends at McHamberger need your McHelpTM again. As part of their new marketing campaign, they are considering selling "rollable grease" and plan on having Harrison Ford say "Roll me some grease, Chewie!" in a commercial. The grease will be packed in either a sphere or a cylinder. For an unknown reason, the cylinder must be exactly 15 centimeters high (but you suspect it is because they are making a deal with RedToro, an up-and-coming energy drink). They want to have a program that, given a specified radius, calculates the volume of each container and determines which one has more volume. Design (pseudocode) and implement (source) this program. See the appendix for the formulas.
Sample run 1:
Enter the radius: 1
Cylinder volume: 47.12388980384689
Sphere volume: 4.1887902047863905
You can put more grease in the cylinder!
Sample run 2:
Enter the radius: 7
Cylinder volume: 2309.070600388498
Sphere volume: 1436.755040241732
You can put more grease in the cylinder!
Sample run 3:
Enter the radius: 12
Cylinder volume: 6785.840131753953
Sphere volume: 7238.229473870883
You can put more grease in the sphere!
Program 3: Καλημερα! For this program, you'll use a switch statement to implement a simple language translator. You must translate a minimum of the following words into a language of your choice (perhaps Klingon?): "Hello", "Goodbye", "food", "water", "where is", "I want". Your task is to design (in pseudocode) and implement (in source code) a program that reads in a word/phrase in English and prints that word/phrase out in another language. If the word is not available, you must let the user know.
Sample run 1:
Enter a word or phrase: Food
Φαγητo
Sample run 2:
Enter a word or phrase: Where is
Που εìναι
Sample run 3:
Enter a word or phrase: McGreaseTM
I cannot translate that word
Program 4: In 1789, Benjamin Franklin is known to have written "Our new Constitution is now established, and has an appearance that promises permanency; but in this world nothing can be said to be certain, except death and taxes." Our federal tax system is a "graduated" tax system which is broken into seven segments. Essentially, the more you make, the higher your tax rate. For 2018, you can find the tax brackets here. Your task is to design (pseudocode) and implement (source code) a program that asks the user for a salary and calculates the federal tax owed. Note, that only the money above a particular tax bracket gets taxed at the higher rate. For example, if someone makes $10,000 a year, the first $9525 gets taxed at 10%. The "excess" above that ($475) gets taxed at 12%. Note: work through at least three (3) examples of this by hand before designing the code. It will save you significant time. Still having problems? Have you talked to a GTA recently?
Sample run 1:
Enter your salary to the nearest dollar: 2000
Total tax owed is: $200
Sample run 2:
Enter your salary to the nearest dollar: 40000
Total tax owed is: $4739
Sample run 3:
Enter your salary to the nearest dollar: 100000
Total tax owed is: $18289
Submission -
Part 1: Pseudocode:
1. Review the assignment submission requirements and grading guidelines.
2. Upload the pseudocode files (Word doc or PDF) to the assignment submission folder in D2L.
3. The files must be uploaded to D2L by the due date.
Part 2: Source Code:
1. Review the assignment submission requirements and grading guidelines.
2. Upload the source code files to the assignment submission folder in D2L.
3. The files must be uploaded to D2L by the due date.
Attachment:- Assignment File.rar