Program:
import java.util.*;
class Student
{
String name;
int yearInSchool;
double gpa;
Student(String name,int yearInSchool,double gpa)
{
this.name=name;
this.yearInSchool=yearInSchool;
this.gpa=gpa;
}
public String toString()
{
String output="";
output=output+"Name: "+name+"\n";
output=output+"Year in School: "+yearInSchool+"\n";
output=output+"GPA: "+gpa+"\n";
return output;
}
}
class Test
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.print("\nEnter Name: ");
String nm=sc.nextLine();
System.out.print("Enter year in school: ");
int year=sc.nextInt();
System.out.print("Enter GPA: ");
double gpa1=sc.nextDouble();
System.out.println("\n");
Student student=new Student(nm,year,gpa1);
System.out.println("Student Details: ");
System.out.println("------------------------------\n");
System.out.println(student+"\n");
}
}
Output:

JAVA Problem: Student is a class that has the following instance variables: name (a String), yearInSchool...