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
user100 [1]
3 years ago
7

In this assignment, you will create a flashcard app for teaching addition and multiplication. The student will choose the type o

f problem, how many they want to solve, and the maximum operand to include in each problem. The program will keep track of how many problems the student answered correctly and report that number along with their percentage. It will then repeat the process, allowing the student to choose a different kind of problem for the next round. Here is an example of how the program should work:
*******************************
Electronic Math Tutor
*******************************
Choose the type of problem:
1. Addition
2. Multiplication
3. Mixed
4. Quit
Enter your choice: 1
How many problems? 3
Largest operand? 12
10 + 8 = ? 17
Incorrect. The answer is 18.
0 + 5 = ? 5
Correct!
7 + 11 = ? 18
Correct!
You answered 2 out of 3 correctly.
Your average was 66.67.
Choose the type of problem:
1. Addition
2. Multiplication
3. Mixed
4. Quit
Computers and Technology
1 answer:
Anna11 [10]3 years ago
3 0

Answer:

See explaination

Explanation:

import java.util.*;

import java.lang.Math;

public class Main

{

public static double getRandomDoubleBetweenRange (double min, double max)

{

double x = (Math.random () * ((max - min) + 1)) + min;

return x;

}

public static void main (String[]args)

{

int option, number_of_problems, correct_answer;

double max_operand, average =

0, user_answer, sum, first_number, second_number, multiply,

sum_or_multiply;

Scanner user_input = new Scanner (System.in);

do

{

System.out.println

("Choose the type of problem: \n1. Addition \n2. Multiplication \n3. Mixed \n4. Quit");

option = user_input.nextInt ();

switch (option)

{

case 1:

correct_answer = 0;

System.out.println ("How many problems?");

number_of_problems = user_input.nextInt ();

System.out.println ("Largest operand?");

max_operand = user_input.nextDouble ();

for (int i = 0; i < number_of_problems; i++)

{

first_number = getRandomDoubleBetweenRange (0, max_operand);

second_number = getRandomDoubleBetweenRange (0, max_operand);

System.out.println (first_number + " + " + second_number +

" = ?");

user_answer = user_input.nextDouble ();

sum = first_number + second_number;

if (sum == user_answer)

{

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

correct_answer = correct_answer + 1;

}

else

{

System.out.println ("Incorrect, The Correct answer is " +

sum);

}

}

average = correct_answer * 100 / number_of_problems;

System.out.println ("You answered " + correct_answer +

" out of " + number_of_problems +

" correctly. Your average was " + average);

break;

case 2:

correct_answer = 0;

System.out.println ("How many problems?");

number_of_problems = user_input.nextInt ();

System.out.println ("Largest operand?");

max_operand = user_input.nextDouble ();

for (int i = 0; i < number_of_problems; i++)

{

first_number = getRandomDoubleBetweenRange (0, max_operand);

second_number = getRandomDoubleBetweenRange (0, max_operand);

System.out.println (first_number + " * " + second_number +

" = ?");

user_answer = user_input.nextDouble ();

multiply = first_number * second_number;

if (multiply == user_answer)

{

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

correct_answer = correct_answer + 1;

}

else

{

System.out.println ("Incorrect, The Correct answer is " +

multiply);

}

}

average = correct_answer * 100 / number_of_problems;

System.out.println ("You answered " + correct_answer +

" out of " + number_of_problems +

" correctly. Your average was " + average);

break;

case 3:

correct_answer = 0;

System.out.println ("How many problems?");

number_of_problems = user_input.nextInt ();

System.out.println ("Largest operand?");

max_operand = user_input.nextDouble ();

for (int i = 1; i <= number_of_problems; i++)

{

first_number = getRandomDoubleBetweenRange (0, max_operand);

second_number = getRandomDoubleBetweenRange (0, max_operand);

if (i % 2 == 1)

{

System.out.println (first_number + " + " + second_number +

" = ?");

user_answer = user_input.nextDouble ();

sum_or_multiply = first_number + second_number;

if (sum_or_multiply == user_answer)

{

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

correct_answer = correct_answer + 1;

}

else

{

System.

out.println ("Incorrect, The Correct answer is " +

sum_or_multiply);

}

}

else

{

System.out.println (first_number + " * " + second_number +

" = ?");

user_answer = user_input.nextDouble ();

sum_or_multiply = first_number * second_number;

if (sum_or_multiply == user_answer)

{

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

correct_answer = correct_answer + 1;

}

else

{

System.

out.println ("Incorrect, The Correct answer is " +

sum_or_multiply);

}

}

}

average = correct_answer * 100 / number_of_problems;

System.out.println ("You answered " + correct_answer +

" out of " + number_of_problems +

" correctly. Your average was " + average);

break;

case 4:

System.out.println ("Thanks for playing.");

break;

default:

System.out.println ("Please choose a valid option");

break;

}

}

while (option != 4);

}

}

You might be interested in
What is a cyber crime?<br><br>help
algol [13]

Answer:

cyber crime, also called computer crime, the use of a computer as an instrument to further illegal ends, such as committing fraud, trafficking in child p0®n0graphy and intellectual property, stealing identities, or violating privacy. Cyber crime, especially through the Internet, has grown in importance as the computer has become central to commerce, entertainment, and government.

3 0
2 years ago
Read 2 more answers
Which diagram is NOT a good model of 3÷14?
swat32
I need a pic for this
7 0
3 years ago
Read 2 more answers
                                                       HELP PLEASE 
Marina CMI [18]
Your answer should be mode







5 0
3 years ago
Read 2 more answers
How does a typewriter involve math and science?
patriot [66]
You have a specific number of words typed a minute and you need to know the science involved in making it
8 0
3 years ago
Read 2 more answers
Refer to the exhibit. An administrator is examining the message in a syslog server. What can be determined from the message? Thi
ad-work [718]

Answer:

This is a notification message for a normal but significant condition

Explanation:

Syslog represents the standard for logging message, it sends messages through UDP port 514. Familiar syslog facilities includes IP, OSPF protocols, etc. The messages from syslog are both about facility and level.

A syslog server is a means through which network devices sends messages about events into a logging server which is called syslog server. Since a syslog protocol supports so many devices, it can also be used to log a good number of events.

8 0
3 years ago
Read 2 more answers
Other questions:
  • Twitter is an example of a __________. social bookmarking website social tagging website microblogging website blogging website
    12·1 answer
  • Darpa was created to
    13·1 answer
  • The computer component that makes sure that instructions are decoded and executed properly is the ___________.
    11·2 answers
  • What is the internet?
    5·2 answers
  • Prompt the user to input an integer, a double, a character, and a string, storing each into separate variables. Then, output tho
    9·1 answer
  • Where is an ideal location to build a ground based observatory?
    10·1 answer
  • Differences between electromechanical era and electronic era in point.<br>PLZ HELP​
    6·1 answer
  • Suppose you are choosing between four different desktop computers: one is Apple MacIntosh and the other three are PC-compatible
    15·1 answer
  • You want to make sure that a set of servers only accepts traffic for specific network services. You have verified that the serve
    7·1 answer
  • Write code which takes two inputs from the user, a number of sides followed by a side length, then creates a regular polygon wit
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!