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
Alex
4 years ago
13

Java Programming: Loops and Conditionals

Engineering
1 answer:
velikii [3]4 years ago
8 0

Answer:

  1. import java.util.Scanner;
  2. import java.util.Random;
  3. public class Main {
  4.    public static void main(String[] args) {
  5.        Scanner input = new Scanner(System.in);
  6.        Random rand = new Random();
  7.        System.out.print("Enter number of questions you wish to practice: ");
  8.        int n = input.nextInt();
  9.        int i = 1;
  10.        while(i <= n){
  11.            int num1 = 1 + rand.nextInt(10);
  12.            int num2 = 1 + rand.nextInt(10);
  13.            int answer = num1 * num2;
  14.            System.out.print("Question " + i + ": " + num1 + " x " + num2 + " = ");
  15.            int response = input.nextInt();
  16.            if(response == answer){
  17.                System.out.println("Correct answer!");
  18.            }
  19.            else{
  20.                System.out.println("Wrong answer. It should be " + answer);
  21.            }
  22.            i++;
  23.        }
  24.    }
  25. }

Explanation:

Firstly, we import Scanner and Random classes (Line 1-2) as we need to get user input for number of questions and generate random number in each question.

Next, create a Scanner and Random object (Line 7-8).  Prompt user to input number of question and get the input using the Scanner object (Line 10-11).

Next create a while loop and set the condition to loop for n number of times (based on number of questions) (Line 14). In the loop, use Random object nextInt method to generate two integers between 1 -10 (Line 15-16). Prompt user to input an answer using the Scanner object (Line 18-19). If the response is matched with answer print a correct message (Line 21-22) other wise inform user they write a wrong answer and show the correct answer (Line 24-25).

You might be interested in
if two or more resistors are connected in parallel, the total resistance is _ than any single resistor
Andreas93 [3]
Parallel Resistor Equation
If the two resistances or impedances in parallel are equal and of the same value, then the total or equivalent resistance, RT is equal to half the value of one resistor. That is equal to R/2 and for three equal resistors in parallel, R/3, etc.
7 0
3 years ago
The Ohm's Law formula used to calculate Voltage is:​
Bogdan [553]

Answer:

V (voltage) = I (current) * R (resistor)

3 0
3 years ago
In a parallel one-dimensional flow in the positive x direction, the velocity varies linearly from zero at y = 0 to 32 m/s at y =
monitta

Answer:

Ψ = 10(y^2) + c

<em><u>y = 1.067m</u></em>

Explanation:

since the flow is one dimensional in positive X direction, the only velocity component is in X, which is denoted by u

while u is a function of y

we find the u in terms of y; u varies linearly wih y

we use similiraty to find the relation

32/1.6 =<em>u/y</em>

<em><u>u = 20y</u></em>

<em><u>Ψ = ∫20ydy</u></em>

<em><u>Ψ = 10(y^2) + c</u></em>

<em><u>(b)</u></em>

<em><u>the flow is half below y = 1.6*(2/3)=1.067 m</u></em>

<em><u>this is because at two third of the height of a triangle lies the centroid of triangle. since the velocity profile forms a right angled triangle , its height is 1.6 m . the flow is halved at y = 1.067m</u></em>

3 0
3 years ago
5. Usually, loads of more than
Reika [66]
50 is the answer!! aka B
7 0
3 years ago
A metal with a BCC structure, such as iron, usually exhibits which mechanical property?
elena-s [515]

Answer:

C can i have brainliest pleaseee

Explanation:

6 0
3 years ago
Other questions:
  • WILL GIVE BRAINLIEST
    11·1 answer
  • For a gearbox power and efficiency test apparatus that accommodates interchangeable gearboxes, drive up to 0.5kW. How to select
    12·1 answer
  • Which of the following is true of the difference between film acting and stage acting?
    5·1 answer
  • Which phase of DevSecOps emphasizes reliability, performance, and scaling
    13·1 answer
  • A car of length 15 ft. approaches a signalized intersection at 45 mph when the light changes to yellow. The vehicle is 300 ft. f
    13·1 answer
  • Assume that light of wavelength 6000A is coming from a star. What is the limit of resolution of a telescope whose objective has
    7·1 answer
  • A bar having a length of 5 in. and cross-sectional area of 0.7 i n . 2 is subjected to an axial force of 8000 lb. If the bar str
    13·1 answer
  • 1. What is resilience engineering and how does it pertain to the current<br>corona virus crisis? ​
    14·1 answer
  • Extra points!!!!! <br><br> List the general types of housing<br> (Example: condo)
    12·2 answers
  • Describe how you would control employee exposure to excessive noise in a mining environment
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!