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 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 (
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
