Help with Java math.Random

timer Asked: Jan 21st, 2013

Question Description

I’m studying for my Programming class and need an explanation.

I have a code I need (I am a school student and before you say figure it out on your own, stop while you can.) and I am Stuck. I need to make 4 modifications to this code and I can't seem to do any of them.

The I am Attempting to Make:

/* Name: Math.Random Mods

Author: Ryroan

Date: January 21st 2013 */

import javax.swing.*;

public class Summative2

public static void main (String args[])
{ int value; int value2,Answer; int value3; int value4; int counter; int input; String word; String word2; String output = "", output1 = ""; JOptionPane.showMessageDialog (null, "Welcome. Press OK to begin", "Random Numbers Game", JOptionPane.QUESTION_MESSAGE); for (int counter2 = 1 ; counter2 <= 10 ; counter2++) { value = 1 + (int) (Math.random () * 9); value2 = 1 + (int) (Math.random () * 9); do{ output = value + " * " + value2; output1 = JOptionPane.showInputDialog ("What is " + output + "?"); input = Integer.parseInt (output1); Answer = value*value2; value3 = 1 + (int) (Math.random() * 4); { switch(value3) { case 1: word = "Awesome"; break; case 2: word = "Perfect"; break; case 3: word = "Flawless"; break; case 4: word = "YOU'RE UNSTOPPABLE"; break; default: break; } } value4 = 1 + (int) (Math.random() * 3); { switch(value4) { case 1: word2 = "Try Again"; break; case 2: word2 = "Sorry"; break; case 3: word2 = "Don't give up."; break; case 4: word2 = "Durrrrrr"; break; default: break; } } if (input != Answer) JOptionPane.showMessageDialog (null, "NOPE", "FAIL", JOptionPane.ERROR_MESSAGE);

JOptionPane.showMessageDialog (null, "CORRECT", "PASS", JOptionPane.INFORMATION_MESSAGE);

} while (input != Answer); } System.exit (0); } }
What The Mods need to be:
Modification #1: Modify the program from assignment 13.Random Numbers so the various comments are printed for each correct answer and each incorrect answer as follows:

Responses to a correct answer
Very good!
Nice work!
Keep up the good work!

Responses to an incorrect answer
No. Please try again.
Wrong. Try once more.
Don’t give up.

Use random-number generation to choose a number from 1 to 4 that will be used to select an appropriate response to each answer. Use a switch structure to issue the responses.
More sophisticated computer-aided instruction systems monitor the student’s performance over a period of time. The decision to begin a new topic is often based on the student’s success with previous topics.

Modification #2: Modify the program to count the number of correct and incorrect responses typed by the student. After the student types 10 answers, your program should calculate the percentage of correct responses. If the percentage is lower than 75%, print “Please ask your instructor for extra help” and reset the program.

Modification #3: Modify the program to allow the user to enter a grade-level capability. A grade level of 1 means to use only single-digit numbers in the problems, and a grade level of 2 means to use numbers as large as two digits.

Modification #4: Modify the program to allow to user to pick the type of arithmetic problems he or she wishes to study. An option of 1 means addition problems only, 2 means subtraction problems only, 3 means multiplication problems only, 4 means division problems only and 5 means to intermix randomly problems of all these types

All help is very much appreciated. 

Student has agreed that all tutoring, explanations, and answers provided by the tutor will be used to help in the learning process and in accordance with Studypool's honor code & terms of service.

This question has not been answered.

Create a free account to get help with this and any other question!

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors