Which loop (while, do-while, or for) is best to use in the following situations?
A) The user must enter a set of exactly 14 numbers.
B) A menu must be displayed for the user to make a selection.
C) A calculation must be made an unknown number of times (maybe even no times).
D) A series of numbers must be entered by the user, terminated by a sentinel value.
E) A series of values must be entered. The user specifies exactly how many.
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Starting Out With C++: Early Objects (10th Edition)
Additional Engineering Textbook Solutions
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Starting Out with Java: Early Objects (6th Edition)
Starting Out with C++ from Control Structures to Objects (8th Edition)
- Remaining Time: 54 minutes, 49 seconds. * Question Completion Status: QUESTION 19 Write a Java program that prompts the user to enter the School Grade Level of a student and then calculate their discount amount in the regular fees structure offered during this pandemic situation. By using the below table, calculate their discount amount from the amount of the regular fee and then print the discount amount in OMR by using the appropriate selection structure. (Assume the user is entering a maximum Grade level is 12) discount amount = Regular Fees * percentage of discount rate School Grade Level Regular Fees in OMR Discount Rate >9 and 6 and 3 and 0 and <=3 30.500 5% otherwise 20.400 No discount T T T Arial 3 (12pt) v T -E E- 只i ン Click Save and Submit to save and submit. Click Save All Answers to save all answers. Save All Answers TOSHIBA F5 F6 F7 F8 F9 F10 F11 F12 INS SCNULL LOCK AD & 67 7 V 8A9 4 0arrow_forwardIn C#arrow_forwardWhich is correct option for below question. Options are 0,7,none of these. With proper explanationarrow_forward
- LAB ASSIGNMENTS, CONT. 2. sandwich.py - follow the instructions below. You may adjust the food items to include your personal favorites. • It uses all of our standard mipo_ex features. • The menu should have numbered or letter options. Sandwich Maker Write a program that asks users for their sandwich preferences. The program should use PylnputPlus to ensure that they enter valid input, such as: Using inputMenu() for a bread type: wheat, white, or sourdough. Using inputMenu() for a protein type: chicken, turkey, ham, or tofu. Using inputYesNo() to ask if they want cheese. If so, using inputMenu() to ask for a cheese type: cheddar, Swiss, or mozzarella. Using inputYesNo() to ask if they want mayo, mustard, lettuce, or tomato. Using inputlnt() to ask how many sandwiches they want. Make sure this number is 1 or 120 00T 110 more. Come up with prices for each of these options, and have your program display all the choices and their prices plus a total cost at the very end. 3 130arrow_forwardAlert dont submit AI generated answer.arrow_forwardSlide Type Slide Exercise # 3: Write a program that first asks the user to type today's price for one dollar in Japanese yen, then reads US dollar values and converts each to yen. Use 0 as a sentinel. • The following are sample runs of the program. Slide Type Enter today's price in yens for 1 $: 105.69 Enter amount in dollars to convert: (0 to quit) 200 200.00 dollars = 21138.00 yens Enter amount in dollars to convert: (0 to quit) 500 500.00 dollars = 52845.00 yens Enter amount in dollars to convert: (0 to quit) 100 100.00 dollars = 10569.00 yens Enter amount in dollars to convert: (0 to quit) e Slide Type Enter today's price in yens for 1 $: 105.6 Enter amount in dollars to convert: (0 to quit) e Slide Type # Exercises # 3 Source Codearrow_forward
- Casel: Write a menu driven program that allows you to visit cities ofman in random order with following options.1: Visit a city2: Go to previous city3: Quit theprogramWhen user presses 1: program asks user to enter the city name, andthen display that the city has been visited. Please note user can visit acity any number of timesWhen user presses 2: Program takes you back to the previous cityWhen user presses 3: Program terminatesSee the below example how program interacts with the user:C:> 1: Visit a cityprogramEnter your choice2: Go to previous city3: Quit thePlease enter a city to visit.MuscatYou are in Muscat now.Enter your choice.1: Visit a city2: Go to previous cityPlease enter a city to visit.IbraYou are in Ibra noW.Enter your choice.1: Visit a city2: Go to previous cityPlease enter a city to visit.SoharYou are in Sohar now.Enter your choice.1: Visit a city2You are in Ibra now.2: Go to previous cityEnter your choice.1: Visit a city2: Go to previous cityPlease enter a city to…arrow_forwardWrite a while loop which prompts the user for the name of a drink and the cost. Add these new items to the drinks_dict. When the user enters "quit", exit the loop. Be sure to cast the value for the cost to a float. Spring Water 1.25 Sparkling Water 2.00 exit Use the values() method to access the values in drinks_dict. Use a loop to print out the values. Use the keys() method to access the keys in drinks_dict. Use a loop to print out the keys. Print the code and the output from the Python Shell. Compute the sum of all of the values for the drinks. Print out the sum. Print the code and the output from the Python Shell. Write a function named find_drink_function(0 that takes two parameters a dictionary and a key: If the key is in the dictionary, return True, otherwise return False. Call the function from within main with the following arguments: drinks_dict and "Tea". Assign the returned Boolean value to a variable found. Print out the value of found. Print the code and the output from…arrow_forward• Use a while loop • Use multiple loop controlling conditions • Use a boolean method • Use the increment operator • Extra credit: Reuse earlier code and call two methods from main Details: This assignment will be completed using the Eclipse IDE. Cut and paste your code from Eclipse into the Assignment text window. This is another password program. In this case, your code is simply going to ask for a username and password, and then check the input against four users. The program will give the user three tries to input the correct username-password combination. There will be four acceptable user-password combinations: • alpha-alpha1 • beta-beta1 • gamma-gamma1 • delta - delta1 If the user types in one of the correct username-password combinations, then the program will output: "Login successful." Here are a couple of example runs (but your code needs to work for all four user-password combinations): Username: beta Type your current password: beta1 Login successful. Username: delta Type…arrow_forward
- Question#2. The distance a vehicle travels can be calculated as fallout: Distance = Speed * Time For example, if a train travels 60 miles-per-hour for three hours, the distance [raveled is 120 miles. Write a program that asks for the speed of a vehicle (in miles-per-hour) and the number of hours it has traveled. It should use a loop to display the distance a vehicle has traveled for each hour of a time period specified by the user. For example, if a vehicle is traveling at 40 mph far a three-hour time period, it should display a report similar to the one chat follows: Hour Distance Traveled 1 90 2 100 3 150 Input Validation: Do not accept a negative number for speed and do not accept any value les than 1 for time traveled.arrow_forwardVolume and Area of a Regular Icosahedron An icosahedron is a regular polyhedron with 20 congruent equilateral triangular faces. Ask the user to supply the length of one of the edges (one side of a triangular face) and then calculate the total surface area and volume of the icosahedron. Report the answers and then repeat. Your program should loop until the value 0 is entered for the radius – and then it should promptly exit. Only positive numbers are allowed for the length of the edge. ???? =? √?∗?? ??????=?/?? (?+ √?)∗ ?3 assemblyarrow_forwardVolume and Area of a Regular Icosahedron An icosahedron is a regular polyhedron with 20 congruent equilateral triangular faces. Ask the user to supply the length of one of the edges (one side of a triangular face) and then calculate the total surface area and volume of the icosahedron. Report the answers and then repeat. Your program should loop until the value 0 is entered for the radius – and then it should promptly exit. Only positive numbers are allowed for the length of the edge. ???? =? √?∗?? ??????=?/?? (?+ √?)∗ ?3arrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning