Rewrite below guessbirthday

Assignment Help Basic Computer Science
Reference no: EM132253935

Program: (Guess birthday) Rewrite below 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.

*** Please change the input answers from digits to using words. In this case "yes" or "no". Additionally we want to have them code the responses to account for user variability so that YES, Yes, yes, Y and y are all valid. So we need the student to use: if (answer.equalsIgnoreCase("yes")||answer.equalsIgnoreCase("y"))

Need to make adjustments to below program

import java.util.Scanner;

public class Listing04_3 {
  public static void main(String[] args) {
    String set1 =
      " 1  3  5  7n" +
      " 9 11 13 15n" +
      "17 19 21 23n" +
      "25 27 29 31";

    String set2 =
      " 2  3  6  7n" +
      "10 11 14 15n" +
      "18 19 22 23n" +
      "26 27 30 31";

    String set3 =
      " 4  5  6  7n" +
      "12 13 14 15n" +
      "20 21 22 23n" +
      "28 29 30 31";

    String set4 =
      " 8  9 10 11n" +
      "12 13 14 15n" +
      "24 25 26 27n" +
      "28 29 30 31";

    String set5 =
      "16 17 18 19n" +
      "20 21 22 23n" +
      "24 25 26 27n" +
      "28 29 30 31";

    int day = 0;

    // Create a Scanner
    Scanner input = new Scanner(System.in);

    // Prompt the user to answer questions
    System.out.print("Is your birthday in Set1?n");
    System.out.print(set1);
    System.out.print("nEnter 0 for No and 1 for Yes: ");
    int answer = input.nextInt();

    if (answer == 1)
      day += 1;

    // Prompt the user to answer questions
    System.out.print("nIs your birthday in Set2?n");
    System.out.print(set2);
    System.out.print("nEnter 0 for No and 1 for Yes: ");
    answer = input.nextInt();

    if (answer == 1)
      day += 2;

    // Prompt the user to answer questions
    System.out.print("Is your birthday in Set3?n");
    System.out.print(set3);
    System.out.print("nEnter 0 for No and 1 for Yes: ");
    answer = input.nextInt();

    if (answer == 1)
      day += 4;

    // Prompt the user to answer questions
    System.out.print("nIs your birthday in Set4?n");
    System.out.print(set4);
    System.out.print("nEnter 0 for No and 1 for Yes: ");
    answer = input.nextInt();

    if (answer == 1)
      day += 8;

    // Prompt the user to answer questions
    System.out.print("nIs your birthday in Set5?n");
    System.out.print(set5);
    System.out.print("nEnter 0 for No and 1 for Yes: ");
    answer = input.nextInt();

    if (answer == 1)
      day += 16;

    System.out.println("nYour birthday is " + day + "!");
  }
}

Reference no: EM132253935

Questions Cloud

Release from the semaphore queue is based on fifo : Fill in the Gant chart based on these conditions: (P, V, and context switch operations are instantaneous).Process P1 starts at time 0
What is the point estimate of the population mean : What is the point estimate of the population mean? Develop a 98% confidence interval for the population mean.
Evaluate three communication strategies : Elaborate on the relationship between resistance to change and communication. Evaluate three (3) communication strategies.
Use conditional formatting : An example for when you would format and use conditional formatting
Rewrite below guessbirthday : Rewrite below 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.
Application of the concepts of employee relations : Discuss, analysis, and application of the concepts of Employee Relations; Alternative Dispute Resolution; and choosing the appropriate type of Business Entity;
Define business management aspects related to outsourcing : The CEO would like to consider outsourcing his manufacturing operations if labor can be supplied cheaper overseas than in the U.S. Create an argument either.
What circumstances would ethically justify a government : what circumstances would ethically justify a government or private company in restricting information made available to the public during a disaster
Countries will be targeted for walmart future growth : What group of countries will be targeted for Walmart’s future growth? What are the attractive nees and risk profiles of these countries?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd