Question: Rewrite Listing 4.3, GuessBirthday.java, to prompt the user to enter the character Y for Yes and N for No rather than entering 1 for Yes
Rewrite Listing 4.3, GuessBirthday.java, to prompt the user to enter the character Y for Yes and N for No rather than entering 1 for Yes and 0 for No.

![main(String[] args) { String setl = "1 3 5 7 " +](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2022/11/636a7232be03c_434636a7232acfea.jpg)


1 import java.util.Scanner; 2 3 public class GuessBirthday { public static void main(String[] args) { String setl = "1 3 5 7 " + " 9 11 13 15 " + "17 19 21 23 " + "25 27 29 31"; 4 5 10 String set2 "2 3 6 7 " + 11 12 13 "10 11 14 15 " + "18 19 22 23 " + "26 27 30 31"; 14 15 16 17 18 String set3 = " 4 5 6 7 " + "12 13 14 15 " + "20 21 22 23 " + "28 29 30 31"; 19 20 21 22 23 String set4 = " 8 9 10 11 " + "12 13 14 15 " + "24 25 26 27 " + "28 29 30 31"; 24 25 26 27 28 29 String set5 = "16 17 18 19 " + "20 21 22 23 " + "24 25 26 27 " + "28 29 30 31"; 30 31 32 33 34 35 int day - 0; 36 // Create a Scanner Scanner input = new Scanner(System.in); 37 38 39 // Prompt the user to answer questions System.out.print ("Is your birthday in Set1? "); System.out.print(set1); System.out.print(" Enter 0 for No and 1 for Yes: "); int answer = input.nextInt (); 40 41 42 43 44 45 46 if (answer == 1) day += 1; 47 48 // Prompt the user to answer questions System.out.print(" Is your birthday in Set2? "); System.out.print(set2); System.out.print(" Enter 0 for No and 1 for Yes: "); answer = input.nextInt(); 49 50 51 52 53 54 55 if (answer -- 1) 56 day += 2; 57 // Prompt the user to answer questions System.out.print("Is your birthday in Set3? "); System.out.print(set3); System.out.print(" Enter 0 for No and 1 for Yes: "); answer = input.nextInt(); 58 59 60 61 62 63 64 if (answer == 1) day +- 4; 65 66 67 // Prompt the user to answer questions System.out.print(" Is your birthday in Set4? "); System.out.print(set4); System.out.print(" Enter 0 for No and 1 for Yes: "); answer = input.nextInt(); 68 69 70 71 72
Step by Step Solution
3.30 Rating (165 Votes )
There are 3 Steps involved in it
Program Plan Create a class called GuessBirthday Initialize the main method with variables sett set2 set3 set4 set5 and s as strings day as integer and answer as character Assign sett set2 seta set4 s... View full answer
Get step-by-step solutions from verified subject matter experts
