# Thread: Confused on how to start this Math program

1. Member
Join Date
Mar 2011
Location
San Diego, CA
Posts
34
Rep Power
0

## Confused on how to start this Math program

I am confused how to even start this program. Could someone walk me through this? If you could even just show me the "parts" I need to build the program (ie: start with instance variable, then add .....". I am seriously lost here so any help is appreciated.

Gary

Here is my algorithm:

USER INPUT: What is the course name?

USER INPUT: What is the section number?

PRINT OUT: You entered Course _______ and Section ________ (private int courseNo, private int sectionNo)

ENTER LOOP AND REPEAT 5 TIMES

PRINT OUT: Are you ready? Press 1 to start, 2 to exit

If input = 1;

The program just generated two random numbers. They are ____ and ____.

Question 1: What is ____ X ____ ?

If correct, provide one of 5 positive responses. If incorrect, provide one of 4 negative responses

Out of 5 questions, here are your results:
Course name ____ and section _____
Total number correct out of 5 is ____
Total number incorrect out of 5 is ______
Percentage of correct responses is _____

If lower than 70%, print “Please see instructor for help:

PRINT OUT: Want to try again? Press 1 to start, 2 to exit

If input = 1, reset to zero and start back at top of loop
If input = 2, exit

HERE IS THE ACTUAL ASSIGNMENT

The student will be given 5 multiplication questions to answer. Use a method that calls the random method of the Math class to produce two random, positive one-digit integers for each multiplication question. For example, assume the integers 6 and 7 are the two positive one-digit integers returned by calls to your math class object. The program should then prompt the user with a question, such as “How much is 6 times7?” Because multiplication by zero is too easy, make sure that your program always generates non-zero random numbers. This requires that you check the two integer values before displaying them to the user.

Ask the student to input the product of the two integers. Your program should calculate the correct answer then compare the student’s response against the calculated answer (in the example, 6*7 = 42). If the student’s answer is correct, the program should display a confirmation message to the student and continue with the next multiplication question. In Computer-Assisted Instruction, one problem that develops is student fatigue. To avoid this potential problem and hold the student’s attention, the responses to the student’s correct answer should be varied as specified below.

You got it!
Exactly right!
Tremendous!
That works!
Nice Guess!

If the answer is wrong, display a message such as one of the following responses.

Don’t give up!
You’ll get it next time!
Try it again!
Sorry. Keep trying!

Create a method that randomly generates one of the 5 correct answer responses shown above. This method should be used whenever the user answers a question correctly. Create another, separate method that randomly generates one of the 4 wrong answer responses. You will use this method whenever the user enters an incorrect answer. Use a switch statement to issue the responses in each one of these methods.

For this exercise, design and implement a class called MathTutor and the methods to support its use. The class should have variables for the course name and course section number. Your class should have two different constructors. One of the constructors should have no input variables and may just print something out to the user. The second constructor should initialize the course name and section number using the two input variables.

Your program should count the number of correct and incorrect answers. Once the student has answered all 5 questions, the program should calculate the percentage of correct responses. Create a method that outputs the total percentage of correct answers, the actual number of correct and incorrect answers, and the course name and section number. After displaying the results of the test session, if the percentage is lower than 70%, the program should display the following message: “Please see your instructor for extra help.” The program should ask the user if they would like to continue practicing and reset the program appropriately for another test session. Create and use a method to reset the counter variables. Make sure to provide the user with the option to quit the program after each run.

Create a driver program to test that your program does what it is intended to do. Try it with two different students using a different constructor for each.

2. This is a very long post. I didn't read it all but it seems like it's pretty step by step. Start as small as you can and work your way up.

3. Member
Join Date
Mar 2011
Location
San Diego, CA
Posts
34
Rep Power
0
Here is what I have so far -
The class definition part -

Java Code:
```public class MathTest

{

private String className = "";
private int courseNumber = 0;
private int randomOne = 0;
private int randomTwo = 0;

public String className()
{
this.className = className;
return className;
}

public int courseNumber()
{
this.courseNumber = courseNumber;
return courseNumber;
}

public int randomOne()
{
this.randomOne = (int) (Math.random() * 10 + 1);
return randomOne;
}

public int randomTwo()
{
this.randomOne = (int) (Math.random() * 10 + 1);
return randomOne;
}

{
}

{
}

{
}

{
}

{
}
}```
Now to test what I have so far, I started writing the driver program. However, I get stuck on getting it to return the random number. Any advice?

Java Code:
```import java.util.*;

public class MathTestDemo
{

public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter name of this class");
String className = keyboard.next();

System.out.println("Enter course number");
int courseNumber = keyboard.nextInt();
System.out.println("You are in " + className + ", course number " + courseNumber);

MathTest one = new MathTest();
one.randomOne();
System.out.println(randomOne);
}

}```

4. Member
Join Date
Mar 2011
Location
San Diego, CA
Posts
34
Rep Power
0
I have also tried
Java Code:
```import java.util.*;

public class MathTestDemo
{

public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter name of this class");
String className = keyboard.next();

System.out.println("Enter course number");
int courseNumber = keyboard.nextInt();
System.out.println("You are in " + className + ", course number " + courseNumber);

MathTest x = new MathTest();
x.getRandomOne();
System.out.println(randomOne);
}

}```

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•