I have been trying to solve this for about a week, but, couldn't do it.Can any please help me on this...
import java.io.*;
import java.util.List;
import java.util.Scanner;
public class Sstudent
{
private String studentName;
private String studentBirthday;
private String studentGPA;
private String studentAddress;
public Sstudent()
{
}
public Sstudent(String nName, String nBirthday, String nGPA, String nAddress)
{
this.studentName = nName;
this.studentBirthday= nBirthday;
this.studentGPA = nGPA;
this.studentAddress= nAddress;
}
public void setStudentName(String newStudentName)
{
studentName = newStudentName;
}
public void setStudentBirthday(String newStudentBirthday)
{
studentBirthday = newStudentBirthday;
}
public void setStudentGpa(String newStudentGPA)
{
studentGPA = newStudentGPA;
}
public void setStudentAddress(String newStudentAddress)
{
studentAddress = newStudentAddress;
}
public String getStudentName()
{
return studentName;
}
public String getStudentBirthday()
{
return studentBirthday;
}
public String getStudentGPA()
{
return studentGPA;
}
public String getStudentAddress()
{
return studentAddress;
}
public static void main(String[] args)
{
try{
BufferedWriter br = new BufferedWriter(
new FileWriter("C:\\Users\\User\\Desktop\\Project\\inp ut.txt"));
Scanner input = new Scanner(System.in);
Sstudent student=new Sstudent();
System.out.println("Enter student details\n");
System.out.println("\nEnter student name");
student.setStudentName(input.nextLine(studentName) );
System.out.println("\nEnter student Birth Day");
student.setStudentBirthday(input.next());
System.out.println("\nEnter student GPA");
student.setStudentGpa(input.next());
System.out.println("\nEnter student Address");
student.setStudentAddress(input.next());
br.close();
}catch(Exception e){
System.out.println("Error!");
}
}
}