Question
I have two classes Student.java and TestStudents.java so I separated them out into different files but am still getting errors and do not know how
I have two classes Student.java and TestStudents.java so I separated them out into different files but am still getting errors and do not know how to fix them.
here is the code and I will leave some screenshots of the errors
Student.java
package david; public class Student { private String name; private int age; private int year; private String studentNum; public Student(String name, int age, int year, String studentNum) { this.name = name; this.age = age; this.year = year; this.studentNum = studentNum; } // Setters and getters (Name, Age, Year and Student Number) public String getName() // name { return name; } public void setName(String name) { this.name = name; } public int getAge() // age { return age; } public void setAge(int age) { this.age = age; } public int getYear() // year { return year; } public void setYear(int year) { this.year = year; } public String getstudentNum() // studentNum { return studentNum; } public void setstudentNum(String studentNum) { this.studentNum = studentNum; } }
TestStudents.java
/ Chris Saenz - G00263842.
// Student information program.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
public class TestStudents
{
public static void main(String[] args) throws IOException
{
System.out.println("============" + "=================");
System.out.println("Students " + "Personal Details");
System.out.println("============" + "=================");
String name;
int age;
int year;
String studentNum;
List studentsList = new ArrayList();
for (int i = 0; i < 2; i++)
{
int studentNumber = (i + 1);
System.out.println("");
System.out.println("Please enter " + "data for student " + studentNumber);
InputStreamReader converter = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(converter);
System.out.println("Enter Student "+ studentNumber + " Name:");
name = in.readLine();
System.out.println("Enter Student " + studentNumber + " Age (Integer):");
age = Integer.valueOf(in.readLine());
System.out.println("Enter Student " + studentNumber + " Year (Integer):");
year = Integer.valueOf(in.readLine());
System.out.println("Enter Student " + studentNumber + " Student Number:");
studentNum = in.readLine();
Student student = new Student(name, age, year, studentNum);
studentsList.add(student); // add student
}
for (int j = 0; j < studentsList.size(); j++)
{
Student st = studentsList.get(j);
System.out.println("Student : " + (j + 1));
System.out.println("Name: " + st.getName() + " - Age: " + st.getAge() + " - Year: " + st.getYear() + " - Student Number: " + st.getstudentNum());
}
}
}
Student.java
Problems vad Declaration Search Console X terminated Student (Jave Application) Abrarg/viaMachines-18.0.1.jaContents/Home/tinjava. (A) Exception in thread "sat" jave.lang.Error: Unresolved compilation problems: Illegal modifier for parameter nase; only final is permitted Illeget modifier for perameter age, only final is permitted Illegal modifier for parameter year: only final is permitted Illegal modifier for parameter studentNm; only final is permitted Syntax error on token "public", record expected after this token Syntax error, insert 3 to complete RecordBody Syntax error, insert to complete LocalVerilibledeclarationStatement Syntax error, insert" to complete Statement Syntax error ce taken vold", record expected Syntax error se token "(", expected after this token at Student.nein Student.javai
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Errors in TestStudentsjava The constructor StudentString int int String is undefined for the type St...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started