Results 1 to 4 of 4
- 04-15-2011, 11:23 PM #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.
Correct Answer responses:
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.
Wrong Answer 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.
- 04-16-2011, 12:35 AM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,068
- Blog Entries
- 3
- Rep Power
- 13
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.
- 04-16-2011, 12:46 AM #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; private int studentAnswer1 = 0; private int studentAnswer2 = 0; private int studentAnswer3 = 0; private int studentAnswer4 = 0; private int studentAnswer5 = 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; } public int studentAnswer1() { this.studentAnswer1 = studentAnswer1; return studentAnswer1; } public int studentAnswer2() { this.studentAnswer2 = studentAnswer1; return studentAnswer2; } public int studentAnswer3() { this.studentAnswer3 = studentAnswer3; return studentAnswer3; } public int studentAnswer4() { this.studentAnswer4 = studentAnswer4; return studentAnswer4; } public int studentAnswer5() { this.studentAnswer5 = studentAnswer5; return studentAnswer5; } }
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); } }
- 04-16-2011, 01:14 AM #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); } }
Similar Threads
-
help w/ PI Math java program
By clemsontigers in forum New To JavaReplies: 12Last Post: 02-17-2011, 08:18 AM -
Start Swing GUI program by Java Web Start with IE in Eclipse debug mode
By albertkao in forum EclipseReplies: 1Last Post: 01-18-2011, 07:27 PM -
Math Program
By stlboi in forum New To JavaReplies: 8Last Post: 04-02-2009, 10:34 PM -
How do you start a Java program from the "Start" menu under Windows?
By ScottVal in forum New To JavaReplies: 5Last Post: 03-20-2009, 11:04 PM -
need help with math for a new program
By gotenks05 in forum New To JavaReplies: 13Last Post: 09-26-2008, 08:32 AM
Bookmarks