Question: CS 250 Lab 05 Main toples: Boolean expressions If statements If-else statements Exercise This lab is designed to give you praction converting an if-else if

 CS 250 Lab 05 Main toples: Boolean expressions If statements If-else
statements Exercise This lab is designed to give you praction converting an
if-else if statement into nested if statenidhits, Getting Started to start this

CS 250 Lab 05 Main toples: Boolean expressions If statements If-else statements Exercise This lab is designed to give you praction converting an if-else if statement into nested if statenidhits, Getting Started to start this exercise, you should: 1. Open eclipse and start a new Java project named Lab05 2. Add a Class (named Labob) to this project. 3. Cut the program from this document and prete (replacing everything) in the Eclipse editor window. Laboja import java.util.Scanner; public class Lab05 public static void main(String[] args) Scanner stdIn - new Scanner(System.in): I System.out.println("c8 201 Restaurant Quide "); String response: char e, f : boolean spicy, fancy: // Ank user for his/her preference Syatem.out.print("Do you like spicy food? ty / a) : "); // Get the next token response - stdin.next(): Look only at first character - response.chart Co): 11 - 'Y' 11 8 -- "Y) apicy - true; els apicy - false; 1/ Ank user for his/her preference System.out.print("Do you want to go to a fancy restaurant? (/) ): // Get the next token ronponge - atdn.bert: // Look only at first character - response.charAt(0); fancy - (1 - 'y' - 'Y'): Malo nuestion 11 spicy RR fancy) System.out.println("I suggest you go to Thai Gardan Palace."); elne if spicy At Ifancy) System.out.println("I suggest you go to Joe's Diner."); else if (apicy Ifancy) System.out.println("I suggest you go to Alberto's Tacqueria.): else if (Ispicy ak fancy System.out.println("I suggest you go to Chez Paris.): atdTo.close(); Problem Description 1. Read through the given code (Lahos javn). 2. This program suggests restaurants based on a user's preferences for spiciness and fancies, Notice that the yes / no answers are converted to boolean results in two different ways, are they equivalent and why? 3. Note: there is a chain of if eleif statements which select and outputs the program's suggestion, based on the user's preference. 4. Your task is to convert this chain of Ifalse if statements into a pair of nested if-else statements. Your new code will look something like this: if ( ) if ( ) System.out.println(.. } else // Beans if (I ) C System.out.println(... 3 3 aloe // means it ) if (ccondition3>) System.out.printla .. 3 else // means it conditions) System.out.println... 3) 3 Note: the conditions are numbered for identification only, this does not imply that they are all unique 5. Indicate which (if any) of the above its or elses above really need to be written in Mock form. Feel free to omit the blocks where they are not needed, in your code. 6. Once you have written your pair of pested if-else statements (a) Make sure that your programs compile and run without errors or warning. (b) Run your program enough times to check all the choloent for correctes. (2) If it runs correctly, then see your TA for a check-off

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!