Results 1 to 4 of 4
  1. #1
    gnng is offline Member
    Join Date
    Mar 2011
    Location
    San Diego, CA
    Posts
    34
    Rep Power
    0

    Default 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.

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    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. #3
    gnng is offline Member
    Join Date
    Mar 2011
    Location
    San Diego, CA
    Posts
    34
    Rep Power
    0

    Default

    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;
    	}
    }
    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. #4
    gnng is offline Member
    Join Date
    Mar 2011
    Location
    San Diego, CA
    Posts
    34
    Rep Power
    0

    Default

    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

  1. help w/ PI Math java program
    By clemsontigers in forum New To Java
    Replies: 12
    Last Post: 02-17-2011, 07:18 AM
  2. Replies: 1
    Last Post: 01-18-2011, 06:27 PM
  3. Math Program
    By stlboi in forum New To Java
    Replies: 8
    Last Post: 04-02-2009, 09:34 PM
  4. Replies: 5
    Last Post: 03-20-2009, 10:04 PM
  5. need help with math for a new program
    By gotenks05 in forum New To Java
    Replies: 13
    Last Post: 09-26-2008, 07:32 AM

Posting Permissions

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