Hello,
I am very new to Java, and I keep running into problems with constructors. Specifically, I am having trouble with this class & driver:
< public class TestScores { private int score1; private int score2; private int score3; // Declares scores 1, 2, and 3 as private integer attributes public TestScore(int s1, int s2, int s3) // Creates a constructor that accepts 3 arguments { score1 = s1; score2 = s2; score3 = s3; } public void setScore1(int s1) // Creats a mutator method that sets score1 (s1) { score1 = s1; } public void setScore2(int s2) // Creats a mutator method that sets score2 (s2) { score2 = s2; } public void setScore3(int s3) // Creats a mutator method that sets score3 (s3) { score3 = s3; } public int getScore1() // Creates an accessor method that gets score1 { return score1; } public int getScore2() // Creates an accessor method that gets score2 { return score2; } public int getScore3() // Creates an accessor method that gets score3 { return score3; } public char getLetterGrade() /* This method determines a letter grade average * based on the 3 scores entered */ { char grade; int score; score = (score1*score2*score3) / 3 if (score < 60) grade = 'F'; else if (score < 70) grade = 'D'; else if (score < 80) grade = 'C'; else if (score = < 90) grade = 'B'; else grade = 'A'; return grade; } } >
< import java.util.Scanner; // Imports the Scanner class public class TestScoreDriver /* This program uses the TestScores class to determine * the letter grade calculated by the average of * the three test scores entered*/ { public static void main(String[] args) { int testScore1, testScore2, testScore3; // Each variable holds 1 test score char letterGrade; // Holds a letter grade // Creates a Scanner object to read input Scanner keyboard = new Scanner(System.in); // Get the first test score System.out.println("Enter your first numeric test score"); testScore1 = keyboard.nextInt(); // Get the second test score System.out.println("Enter your second numeric test score"); testScore2 = keyboard.nextInt(); // Get the third test score System.out.println("Enter your third numeric test score"); testScore3 = keyboard.nextInt(); // Create a TestScores object with the numeric scores TestScores test = new TestScores(testScore1, testScore2, testScore3); // Get the letter grade of the test average letterGrade = test.getLetterGrade(); // Display the grade System.out.println("Your test average grade is " + test.getLetterGrade()); } } >
The error message says "The constructor TestScores(int, int, int) is undefined"
I don't understand this. Please help?