Do you want to play the addition quiz

Assignment Help JAVA Programming
Reference no: EM131597956

I am stuck with this java program. I need to modify it so that it asks the user if they want to play the quiz over and over until the user enters "n" or "N". When they answer N or n, the program will stop.

Here is a sample run:

Do you want to play the Addition Quiz (answer Y or N)? Y

What is 1 + 3? 4

Your answer is correct!

Do you want to play the Addition Quiz (answer Y or N)? Y

What is 1 + 2? 6

Your answer is wrong!

1 + 2 should be 3

Do you want to play the Addition Quiz (answer Y or N)? N

Thanks for playing the Addition Quiz Game! Bye!
__________________________________________________________________________________________

public class Quiz{
public static void main(String[] args) {
// 1. Generate two random single-digit integers
int number1 = (int)(Math.random() * 10);
int number2 = (int)(Math.random() * 10);

// 2. Prompt the student to answer "what is number1 + number2?"
System.out.print("What is " + number1 + " + " + number2 + "? ");
Scanner input = new Scanner(System.in);
int answer = input.nextInt();

// 4. Grade the answer and display the result
String replyString;
if (number1 + number2 == answer)
replyString = "You are correct!";
else
replyString = "Your answer is wrong.n" + number1 + " + "
+ number2 + " should be " + (number1 + number2);

System.out.println(replyString);
}
}

Reference no: EM131597956

Questions Cloud

Which investment type has had the greatest return : Which investment type has had the greatest return since 1925? Compare and contrast the two investments. Specifically, discuss the standard deviation.
Was communication approach taken effective why or why not : Was the communication approach taken effective? Why or Why Not? If the tables were turned, how would you have approached the communication of same information?
What is the frictional unemployment rate : Each? month, 35 new people? (not including the 23lacking required? skills) continue to become? unemployed, but each monthly group.
Apply bronfenbrenners ecological systems theory : Apply either Bronfenbrenner's ecological systems theory or Vygotsky's sociocultural theory to Mila's life to create a hypothesis as to how ?
Do you want to play the addition quiz : Generate two random single-digit integers - Prompt the student to answer "what is number1 + number2?"
What should pounds sell for in dollars per pound : If U.S. dollars sell for £0.60 (British pounds) per dollar, what should pounds sell for in dollars per pound?
Cloning cheapen the value of human lives : Ethically, would human cloning cheapen the value of human lives? Would it allow "pre-selection" of the genes and attributes deemed valuable to continue?
Determine the equilibrium price and quantity in market : You've researched and found that most firms in the market currently experience costs such that TC = 30 + 65Q - 14Q2 + 2.4Q3.
What criteria would you would use to assess a new venture : Why is financial analysis often the entrepreneur's Achilles' heel? What criteria would you would use to assess a new venture's financial strength and viability?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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