There's something wrong with this code. I must implement the TestScores class, but I know I am missing something.

/**
     TestScores class
 */

import java.util.Scanner; // Needed for the Scanner class

// For use in CodeMate, the TestScores class is not declared to be
// public. Normally the class header would be:
//
//  public class TestScores
//
// You should ignore this change.

class TestScores
{
    double test1;
    double test2;
    double test3;

    public void setTest1(double t1)
    {
        test1 = t1;
    }

    public double getTest1() 
    {
        return test1;
    }

    public void setTest2(double t2)
    {
        test2 = t2;
    }

    public double getTest2() 
    {
        return test2;
    }

    public void setTest3(double t3)
    {
        test3 = t3;
    }

    public double getTest3() 
    {
        return test3;
    }

    public double getAverageScore(test1, test2, test3)
    {
        getAverageScore = (test1 + test2 + test3) / 3;
        return getAverageScore;
    }


}

/**
     Chapter 6, Programming Challenge 6
     TestScoresAverage class
 */

public class TestScoresAverage
{
   public static void main(String[] args)
   {
      double test1;        // First test score
      double test2;        // Second test score
      double test3;        // Third test score  

      // Create a Scanner object for keyboard input.
      Scanner keyboard = new Scanner(System.in);

      // Get the first test score.
      System.out.print("Enter test score #1: ");
      test1 = keyboard.nextDouble();

      // Get the second test score.
      System.out.print("Enter test score #2: ");
      test2 = keyboard.nextDouble();

      // Get the third test score.
      System.out.print("Enter test score #3: ");
      test3 = keyboard.nextDouble();

      // Create a TestScores object.      
      TestScores scores = new TestScores(test1, test2, test3);

      // Display the average test score.
      System.out.println("The average test score is " + scores.getAverageScore());
   }
}

Recommended Answers

All 2 Replies

Can you re-post your code in code tags? Just click the (code) button when making a new post and put your code in there.
Also give more explanations about your problem

There's something wrong with this code.

Do you know what is wrong?
Do you get errors? Copy and paste the full text here.
Do you get wrong results? Copy and paste here the results with an explanation of what is wrong and show what you want the results to be.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.