Hi All,
I need help!! Please refer below for my java code. There was error some where inside! But need those expert to help me complete my Java code without error.... Please help!! Thanks alot.
Java Code:
//Import statement for the JoptionPane
import javax.swing.JOp tionPane;
// Definition of class Student
public class Student1 {
//Attributes
private String name;
private int ID;
private String Course;
// create constructor with initialising name, ID and course to "Not allocated", a and "None" respectively.
Student(){
System.out.prin tln ("Student Detail");
name = "Not allocated";
ID = 0;
Course = "None";
}
// create another constructor with Initialising name, ID and course for user to input
Student (String inName, int inID, String inCourse){
name = inName;
ID = inID;
Course = inCourse;
}
// Get the value of attribute Name
public String getName(){
return name;
}
// Get the value of attribute ID
public int getID(){
return ID;
}
// Get the value of attribute Course
public String getCourse(){
return Course;
}
// Show the Student Detail on the screen
public static void main(String args []){
String inName, inID, inCourse;
char name, Course;
int ID;
//Create a dialog box for user to key in the name, ID, & Course.
inName =
JOptionPane.sho wInputDialog("S tudent Name: ");
name = inName.charAt(1 5);
inID =
JOptionPane.sho wInputDialog("S tudent ID: ");
ID = Integer.parseIn t(inID);
inCourse =
JOptionPane.sho wInputDialog("S tudent Course: ");
name = inName.charAt(1 5);
// system output with first constructor
Student Detail1 = new Student ();
System.out.prin tln("Name is: " + Detail1.getName ());
System.out.prin tln("ID is: " + Detail1.getID() );
System.out.prin tln("Course is: " + Detail1.getCour se());
// system output with second constructor
Student Detail2 = new Student (tanchunho, 0407010231, Engineering);
System.out.prin tln("Name is: " + Detail2.getName ());
System.out.prin tln("ID is: " + Detail2.getID() );
System.out.prin tln("Course is: " + Detail2.getCour se());
}
}
I need help!! Please refer below for my java code. There was error some where inside! But need those expert to help me complete my Java code without error.... Please help!! Thanks alot.
Java Code:
//Import statement for the JoptionPane
import javax.swing.JOp tionPane;
// Definition of class Student
public class Student1 {
//Attributes
private String name;
private int ID;
private String Course;
// create constructor with initialising name, ID and course to "Not allocated", a and "None" respectively.
Student(){
System.out.prin tln ("Student Detail");
name = "Not allocated";
ID = 0;
Course = "None";
}
// create another constructor with Initialising name, ID and course for user to input
Student (String inName, int inID, String inCourse){
name = inName;
ID = inID;
Course = inCourse;
}
// Get the value of attribute Name
public String getName(){
return name;
}
// Get the value of attribute ID
public int getID(){
return ID;
}
// Get the value of attribute Course
public String getCourse(){
return Course;
}
// Show the Student Detail on the screen
public static void main(String args []){
String inName, inID, inCourse;
char name, Course;
int ID;
//Create a dialog box for user to key in the name, ID, & Course.
inName =
JOptionPane.sho wInputDialog("S tudent Name: ");
name = inName.charAt(1 5);
inID =
JOptionPane.sho wInputDialog("S tudent ID: ");
ID = Integer.parseIn t(inID);
inCourse =
JOptionPane.sho wInputDialog("S tudent Course: ");
name = inName.charAt(1 5);
// system output with first constructor
Student Detail1 = new Student ();
System.out.prin tln("Name is: " + Detail1.getName ());
System.out.prin tln("ID is: " + Detail1.getID() );
System.out.prin tln("Course is: " + Detail1.getCour se());
// system output with second constructor
Student Detail2 = new Student (tanchunho, 0407010231, Engineering);
System.out.prin tln("Name is: " + Detail2.getName ());
System.out.prin tln("ID is: " + Detail2.getID() );
System.out.prin tln("Course is: " + Detail2.getCour se());
}
}
Comment