Results 1 to 2 of 2
  1. #1
    Hector is offline Member
    Join Date
    Feb 2014
    Location
    Seattle, Washington
    Posts
    9
    Rep Power
    0

    Default Can somone help explain this program to me?

    This is a quiz program that my teacher gave to us to help learn our lesson. he tried to explain it to us but i want really understanding what he was saying. i keep looking over it to try to understand it more, but i really think i need someone to explain whats going on in the Quiz class. here's what he gave us:
    Quiz class:
    Java Code:
    import java.util.Scanner;
    
    public class Quiz{
       int totalQuestions = 25;
       private Question[] questions;
       int current;
       int correct;
       int incorrect;
    
       public Quiz(){
          questions = new Question[totalQuestions];
          current = 0;
          correct = incorrect = 0;
       }
    
       public void add(Question newQuestion)
       {
          if(current < totalQuestions)
             questions[current++] = newQuestion;
       }
    
       public void giveQuiz()
       {
          Scanner scan = new Scanner (System.in);
          for (int i = 0; i < current; i++)
          {
             System.out.println(questions[i].getQuestion());
             
             if (questions[i].answerCorrect(scan.nextLine()))
                correct++;
             else
                incorrect++;
          }
       }
    
       public void giveQuiz(int minComplexity, int maxComplexity)
       {
          Scanner scan = new Scanner (System.in);
          for (int i = 0; i < current; i++)
          {
             int complexity = questions[i].getComplexity();
             if (complexity >= minComplexity && complexity <= maxComplexity)
             {
            	 
                System.out.println(questions[i].getQuestion());
                
                if (questions[i].answerCorrect(scan.nextLine()))
                   correct++;
                else
                   incorrect++;
              }
          }
          if (correct == 0 && incorrect == 0)
             System.out.println("Difficulty error");
       }
    
       public int getNumCorrect()
       {
          return correct;
       }
    
       public int getNumIncorrect()
       {
          return incorrect;
       }
    }
    let me know if you need any further information further explain this program to me.
    thanks in advance!

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default Re: Can somone help explain this program to me?

    What part is confusing for you?

    Can you add some comments to the code showing what you understand and what you need help with?

    Also post the program's output with comments about the parts you don't understand.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. please explain
    By shad0wblade890 in forum Eclipse
    Replies: 7
    Last Post: 03-14-2014, 12:47 PM
  2. Replies: 3
    Last Post: 01-11-2013, 06:52 AM
  3. Help using somone's documentation
    By davetheant in forum New To Java
    Replies: 12
    Last Post: 01-07-2011, 02:17 PM
  4. Replies: 2
    Last Post: 12-13-2010, 01:34 PM
  5. Replies: 3
    Last Post: 12-13-2010, 07:22 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
  •