
Need urgently.Plz use math.random() formula for random numbers and show the output as recquired.
/* Please read all the comments */
/* This division is integer division. You could keep as double type. You can change accordingly */
/* Source code */
import java.io.*; //To get the user input from keyboard
class LearnDivision
{
static BufferedReader br = null; //To read the user input from the keyboard
static int totalCorrectAnswers; //Keep track of correct answers
static int totalQuestionAttempted; //Keep track of total division questions asked
static int score; // For adding the score with correct answers
static String name;
public LearnDivision() throws Exception //Constructor to initilized the object of the class and setup the basic things
{
br = new BufferedReader(new InputStreamReader(System.in)); //Set up the keyboard as input
totalCorrectAnswers = 0 ;
totalQuestionAttempted = 0;
welcomeAndStartLearning();
}
static void welcomeAndStartLearning() throws Exception //As BufferedReader object as input from keyboard can throws Exception
{
//Step 1
System.out.print("Hi. What is your name ? ");
name = br.readLine(); //Read the name
System.out.println("Welcome "+name + ". Are you ready to learn the topic? (Press enter)");
br.readLine(); //Get the input as Enter and go to startLearning
continueLearning();
}
static boolean checkAnswer(int n1,int n2,int response)
{
totalQuestionAttempted++;
if(n1 / n2 == response)
{
totalCorrectAnswers++;
//Add the score 5 for correct answers
score += 5;
return true;
}
return false; // coming here means response was correct
}
static boolean proceedLearning() throws Exception
{
System.out.println("\n\nwill you like to continue or stop. \n(Press 0 if want to stop, else 1 to continue).\t");
int choice = Integer.parseInt(br.readLine());
return (choice==1); //choice is setup with the use input
}
static void continueLearning() throws Exception
{
//Step 2
int MINIMUM = 0;
int MAXIMUM = 100;
int n1 = ((int) (Math.random()*(MAXIMUM - MINIMUM))) + MINIMUM; //Setting number 1
int n2 = ((int) (Math.random()*(MAXIMUM - MINIMUM))) + MINIMUM; //Setting number 2
String appreciateMessage[]={"Wow. Correct Answer.","Great.", "You are Genius."}; //Show any of these appreciate message randomly for correct answer
//Printing the message for question
String incorrectMessage[]={"Sorry. Incorrect Answer.","You could try better.","No. Incorrect Answer."};
System.out.print("what will be the quotient when "+ n1 + " is divided by " + n2+" ?\t");
int response = Integer.parseInt(br.readLine()); //Get the response
boolean isCorrrectAnwer = checkAnswer(n1,n2,response);
if(isCorrrectAnwer)
{
int appreciateMessageIndex = ((int) (Math.random()*(2 - 0)));
System.out.println(appreciateMessage[appreciateMessageIndex]);
}
else
{
int incorrectMessageIndex = ((int) (Math.random()*(2 - 0)));
System.out.println(incorrectMessage[incorrectMessageIndex]);
//Now show the question and answer of that with explaination
System.out.print("\n\nExplanation:\nWhen " + n1 + " is divided by " + n2 +" then quotient would be " + (n1/n2) );
}
//Get User Input if want to proceed learning
if(proceedLearning()) continueLearning();
else
{
//show the results
showResults();
}
}
static void showResults()
{
int totalIncorrectAnswers = 0; // Keep track of total wrong answers
totalIncorrectAnswers = totalQuestionAttempted - totalCorrectAnswers;
//Show the results
String result = "\n\nGreat " + name + ". Weldone.\n";
result += "You attempted total " + totalQuestionAttempted + " questions.\n";
result += "out of which total correct answer is : " + totalCorrectAnswers +"\n";
result += "total incorrect answers is :" + totalIncorrectAnswers +"\n";
result += "total scores for correct answers is: " + score +"\n";
result += "Thanks for learning. Bye.";
System.out.println(result);
}
public static void main(String arg[]) throws Exception
{
//lanuch the assistance
LearnDivision learn = new LearnDivision();
}
}
/* Editor screen */


/* Please refere the below screen for the output of the above source code while running */

/* That's all. Thanks */
Need urgently.Plz use math.random() formula for random numbers and show the output as recquired. Problem (Computer...
Problem (Computer Assisted Instruction) The use of computers in education is referred to as Computer Assisted Instruction (CAI). Develop a Java application that can help an elementary school student learn division of two decimal integer numbers. When the application is launched, its behaviour should be like as described: 1. The application should welcome the learner and ask if ready to learn the topic. Assume the application can assist only to learn division of two integer numbers. 2. If the user...
Write In JAVA: Part 1 The use of computers in education is referred to as computer-assisted instruction (CAI). Write a program that will help an elementary school student learn multiplication. Use a SecureRandom object to produce two positive one-digit integers (you will need to look up how to do this). The program should then prompt the user with a question, such as How much is 6 times 7? The student then inputs the answer. Next, the program checks the student’s...
Programming in C: Write a program that will help an elementary school student learn multiplication. Use the random number generator to produce two positive integers between 1 and 12 inclusive. It should then type a question such as: How much is 6 times 7? The student then types the answer. Your program checks the students’ answer. If it is correct, print a message such as Very good! If the answer is wrong, print a message such as No. Please...
The problem demonstrates the use of the random number generator to recover previously generated random numbers Write a function called randi test that takes two scalar positive integer arguments maxi and n, and retums two output arguments: a row vector of n2 elements and and n-by-n matrix. The two output arguments must contain the exact same set of random integers that fall between 1 and maxi Do this using the random number genertor, not by reshaping the data Example n,v-randi...
In this problem you'll get to use one of Java's random number generators, java.util.Random (see the docs for Random). This class generates a random double precision number uniformly distributed in the range [0.0 ... 1.0). That is, the numbers go from 0 to 1, including 0 but excluding 1. It is a common need in Java programming to generate a random integer number that's uniformly distributed in the range of [0 ... n), such as we saw in the dice...
Hi I need some help in C programing class and I doing one of the exercise so that I can get better at coding. Suppose you are asked to design a software that helps an elementary school student learn multiplication and division of one-digit integer numbers. The software allows the student to select the arithmetic operation she or he wishes to study. The student chooses from a menu one of two arithmetic operations: 1) Multiplication and 2) Division (quotient). Based...
#include<stdio.h>
#include<stdlib.h>
#include <time.h>
int main()
{
/* first you have to let the computer generate a random number.
Then it has to declare how many tries the user has for the game
loop.
we then need the player to enter their guess. After every guess we
have to give an output of how many numbers they have in the right
location
and how many they have the right number. The player will keep
guessing until their 10 tries are...
please use python and provide run result, thank you!
click on pic to make it bigger
For this assignment you will have to investigate the use of the Python random library's random generator function, random.randrange(stop), randrange produces a random integer in the range of 0 to stop-1. You will need to import random at the top of your program. You can find this in the text or using the online resources given in the lectures A Slot Machine Simulation Understand...
Assignment 5 will be way different. It will be more like what
you will receive in a programming shop. By that I mean that some
things are built for you and others you will need to create or
finish. P.S. part of your grade will include: Did you add in the
required files? Did you rename your project? does your linear
searches work? Did you put your code in the correct modules? did
you change modules that you weren't supposed...
The following are screen grabs of the provided files
Thanks so much for your help, and have a nice day!
My Java Programming Teacher Gave me this for practice before the exam, butI can't get it to work, and I need a working version to discuss with my teacher ASAP, and I would like to sleep at some point before the exam. Please Help TEST QUESTION 5: Tamagotchi For this question, you will write a number of classes that you...