1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Serhud [2]
3 years ago
13

Write a program that deliberately contains an endless or infinite while loop. The loop should generate multiplication questions

with single digit random integers. Users can answer the questions and get immediate feedback. After each question, the user should be able to stop the questions and get an overall result. See Example Output.
Computers and Technology
1 answer:
Westkost [7]3 years ago
3 0

Answer:

The Java code is given below with appropriate variable names for better understanding

Explanation:

import java.util.Random;

import java.util.Scanner;

public class MultiplicationQuestions {

   public static void main(String[] args) {

       Scanner scan = new Scanner(System.in);

       Random rand = new Random();

       int n1, n2, result, total = 0, correct = 0;

       char ch = 'y';

       while(ch == 'y'){

           n1 = 1 + rand.nextInt(9);

           n2 = 1 + rand.nextInt(9);

           System.out.print("What is "+n1+" * "+n2+" ? ");

           result = scan.nextInt();

           if(result==n1*n2){

               System.out.println("Correct. Nice work!");

               correct++;

           }

           else{

               System.out.println("Incorrect. The product is "+(n1*n2));

           }

           System.out.print("Want more questions y or n ? ");

           ch = scan.next().charAt(0);

           total++;

       }

       System.out.println("You scored "+correct+" out of "+total);

   }

}

You might be interested in
1. Separate valid and invalid variables:
DedPeter [7]

Firstly we explain the variable and the declaration rule for the variable and further separating the valid and invalid variables.

  • Whenever a user is given a question, variables are data values that can vary. for example  age, CSL, etc.
  • It may alter and during the execution of the program.
  • It's a storage space for memories.
  • It has a name that corresponds to the location.
  • Data is stored in the memory location.

The rule for variable declaration:

  • The names of your variables should be based on the phrases used in the subject area, and they should reflect the variable's function.
  • By removing spaces between the words, you can make variable names. Each word in the name should be capitalized, including prepositions and pronouns that are one letter long.
  • An underscore should never be used to start a variable name.
  • Single-character variable names should be avoided. For loop counters, only short variable names are permitted.
  • After the state that equals the "true" value, name variables that describe binary states ("true" or "false").

The valid variable is:

CSL, Age,CLS,SEE,Stop5for,Give, $shopping, and United.

The invalid variable is:

Mark-sheet, Tel $, Simple Interest, and 545Newton.

Learn more:

brainly.com/question/2684763

5 0
3 years ago
What is the following file format called? inv_nbr, inv_name, inv_cost 876521,battery,45.00
kiruha [24]

The  following file format of  inv_nbr, inv_name, inv_cost is called delimited format.

<h3>What is a delimited file in Excel?</h3>

The term "Delimited" is known to be a term that connote a form of  an  TXT file that tends to make use of tabs or an  CSV file that uses commas to  be able to separate and group your data.

Note also that a  delimited file is seen as a form of a given sequential file that is made up of column delimiters.

Therefore, The  following file format of  inv_nbr, inv_name, inv_cost is called delimited format.

Learn more about text format from

brainly.com/question/16397886

#SPJ1

Multiple Choice

fixed-width format

extensible markup

delimited format

hypertext format

6 0
1 year ago
PLEASE HELP!!!!! (Environmental Science Semester 1)
uranmaximum [27]
I believe the answer would be B, Sorry if I'm wrong! ❤
6 0
2 years ago
Read 2 more answers
Why do astronomers prefer to use the reflecting telescope rather than the refracting telescope to view distant objects in space?
sdas [7]
C is the right answer
7 0
3 years ago
Read 2 more answers
10. This famous designer’s sister took over his clothing line after his assassination in 1997.
rewona [7]

Please find the answers in attached file.

Download docx
8 0
3 years ago
Other questions:
  • Hope wants to add a third use at the end of her
    14·1 answer
  • Using a wireless network without the network owner's permission is known as ________.
    15·1 answer
  • The second row of letters on the keyboard is called the______ row
    14·2 answers
  • Which of the following are examples of software? Check all of the boxes that apply.
    12·2 answers
  • A ____ is a type of program that uses a grid to organize and work with data.
    14·1 answer
  • You can put a small level on your camera to help keep the horizons straight? TRUE OR FALSE
    14·2 answers
  • Written and artistic expressions are protected by
    8·1 answer
  • A desktop computer (named workstation22) can’t connect to the network. A network card was purchased without documentation or dri
    15·1 answer
  • How are actual rocket launches similar to how balloon rockets and canister rockets launch?
    6·1 answer
  • Plz answer the following ​
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!