Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1) (20 points) If Statement. This task is intended to help out at the checkout of a grocery store. Ask the user to enter the

image text in transcribed
1) (20 points) If Statement. This task is intended to help out at the checkout of a grocery store. Ask the user to enter the number of grocery items that they purchased. Assume 8 items can fit per bag (regardless of the size of the items). Calculate the number of bags needed. In this calculation, you should also assume that all items must end up in a bag. So, if a user has 9 items, they need 2 bags (8 in the first and an extra bag for the one additional item). Use an if statement to display one of two grammatically correct statements indicating how many bags are needed: "You only need one bag." or "You need number> bags." For now, you can assume that the user always enters a positive number. Note: You will likely need a second if statement to determine if there are remainder items and, if so, increment the number of bags that you calculated. 2) (15 points) If/else if/else: In this program, a user will be entering a number from 1 to 100. The purpose of the program is to display a message that tells the user whether the number is really low (1-20), low (21-40), in the middle (41-60), high (61-80), or really high (81-100). Using the starter program provided here (https://onlinegdb.com/SJmgnfsBV), insert the if/else if else statement(s) needed to output the appropriate text. Note that this should not be 5 separate if statements - instead, it should be one if statement with "else if" statements that follow. One additional thing to note is that subsequent else if statements are only hit if the previous if statements and else if statements are false. With that, you do not need to "double check" previous relationships that you know must be true. 3) (15 points) Switch Statement. Ask the user to enter a number from 1 to 10 and collect this as an int. Using a switch statement display one of the following statements: . "That number starts with a vowel" "That number starts with an F" "That number starts with an N" "That number starts with an S" "That number starts with a T" Use the fall through feature of the switch statement to maximize efficiency in your code. This means you should stack multiple case statements wherever possible. 4) (15 points) Nested if: Here, we are designing an amusement park ride verification system. First, the system should ask the child for their age. If the child is younger than 5, the program should stop and display "I am sorry, you are too young to ride this ride." If the child is 5 or older, the program should ask them to enter their height in inches. If they are less than 36 inches, the program should display "I am sorry, you are not tall enough to ride this ride." If the child is 36 inches tall or more, the program should display "Have fun, you are allowed to ride this ride!" Using the starter program provided here (https://onlinegdb.com/rytOxXsSN), insert the nested if statement needed to implement this program

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_2

Step: 3

blur-text-image_3

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

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions