So I get an error that says "no suitable constructor found for Student(no arguments constructor)"
/**
* Write a description of class Student here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Student
{
private String name ;
private int test1 ;
private int test2 ;
private int test3 ;
public Student(String nm, int t1, int t2, int t3)
{
name = "";
test1 = 0;
test2 = 0;
test3 = 0;
}
public Student(Student s){
this(s.name, s.test1, s.test2, s.test3);
}
public void setName (String nm)
{ // Set a student's name
name = nm;
}
public String getName ()
{ // Get a student's name
return name;
}
public void setScore (int i, int score){
// Set test i to score
if (i==1) test1 = score;
else if (i == 2) test2 = score;
else test3 = score;
}
public int getScore(int i ){
if (i==1) return test1 ;
else if (i==2) return test2 ;
else return test3 ;
}
public int getAverage(){
int average ;
average = (int) Math.round((test1 + test2 + test3) / 3.0) ;
return average ;
}
public int getHighscore(){
int highScore ;
highScore = test1 ;
highScore = test1 ;
if(test2> highScore) highScore = test2 ;
if(test3> highScore) highScore = test3 ;
return highScore ;
}
public String toString(){
String str ;
str = "Name: " + "\n" +
"Test 1: " + test1 + "\n" +
"Test 2: " + test2 + "\n" +
"Test 3: " + test3 + "\n" +
"Average : " + getAverage() ;
return str ;
}
}
import java.util.Scanner ;
public class StudentApp
{
public static void main(String []args)
{
Student student1 = new Student() ;
Student student2 = new Student() ;
Scanner reader = new Scanner(System.in) ;
String name ;
int score ;
System.out.println("Enter the first student's score: ") ;
name = reader.nextLine() ;
student1.setName(name) ;
int average ;
for(int i =1; i<=3 ; i++)
{
System.out.print("Enter the student's name: ") ;
score = reader.nextInt() ;
student1.setScore(i, score) ;
}
reader.nextLine() ;
System.out.print("Enter the second student's name: ") ;
student2.setName(name) ;
for(int i =1 ; i<=3 ; i++)
{
System.out.print("Enter the student's name: ") ;
score = reader.nextInt() ;
student1.setScore(i, score) ;
}
System.out.println(student1) ;
System.out.println(student2) ;
if (student1.getHighscore() > student2.getHighscore())
{
name = student1.getName ();
score = student2.getAverage() ;
}
else
{
name = student2.getName() ;
score = student2.getAverage() ;
}
System.out.println(name + " has the highest average score: " + score) ;
}
}