Question

In: Computer Science

Create a Java program that receives name, GPA, and graduation year information about a student as...

  1. Create a Java program that receives name, GPA, and graduation year information about a student as user input and prints it to the console.

Please use the following constructs in your program:

  1. Write your code in a Java class.
  2. Define name, GPA and graduation year as variables in our class.
  3. Create separate setter and getter methods for those variables.
  4. Use your main method, to receive the user input.
  5. Initialize an object of the class to call the setter methods and assign values to class variabl
  6. Call the getter methods to print the values.

Solutions

Expert Solution

//GpaYear.java
import java.util.Scanner;

public class GpaYear {
    private double gpa;
    private int graduationYear;

    public GpaYear() {
    }

    public GpaYear(double gpa, int graduationYear) {
        this.gpa = gpa;
        this.graduationYear = graduationYear;
    }

    public double getGpa() {
        return gpa;
    }

    public void setGpa(double gpa) {
        this.gpa = gpa;
    }

    public int getGraduationYear() {
        return graduationYear;
    }

    public void setGraduationYear(int graduationYear) {
        this.graduationYear = graduationYear;
    }

    public static void main(String[] args) {
        GpaYear obj = new GpaYear();
        Scanner scan = new Scanner(System.in);
        double gpa;
        int year;

        System.out.print("Enter gpa: ");
        gpa = scan.nextDouble();

        System.out.print("Enter graduation year: ");
        year = scan.nextInt();

        obj.setGpa(gpa);
        obj.setGraduationYear(year);

        System.out.println("GPA: "+obj.getGpa());
        System.out.println("Graduation year: "+obj.getGraduationYear());
    }
}


Related Solutions

Create a class called Student. Include the following instance variables: name, address, phone, gpa Create all...
Create a class called Student. Include the following instance variables: name, address, phone, gpa Create all of the methods required for a standard user defined class: constructors, accessors, mutators, toString, equals Create the client for testing the Student class Create another class called CourseSection Include instance variables for: course name, days and times course meets (String), description of course, student a, student b, student c (all of type Student) Create all of the methods required for a standard user defined...
In Java create a simple class named student with the following properties: id age gpa credit...
In Java create a simple class named student with the following properties: id age gpa credit hours accomplished Also, create the following methods: Constructors Getters and setters
Create a java program for Student profile with the following requirements. Each Student has: two variables...
Create a java program for Student profile with the following requirements. Each Student has: two variables id, and name. A Student can be initialization with two constructers: Constructer without parameters, that set the id to zero and the name to an empty string. Constructer with tow parameters to initialize the variables id and name by a specific value. Add a set method for each variable that change them to a specific value. Add a get method for each variable which...
Create a program in java with the following information: Design a program that uses an array...
Create a program in java with the following information: Design a program that uses an array with specified values to display the following: The lowest number in the array The highest number in the array The total of the numbers in the array The average of the numbers in the array Initialize an array with these specific 20 numbers: 26 45 56 12 78 74 39 22 5 90 87 32 28 11 93 62 79 53 22 51 example...
JAVA PROGRAMMING Part 1 Create a class Student, with attributes id, first name, last name. (All...
JAVA PROGRAMMING Part 1 Create a class Student, with attributes id, first name, last name. (All the attributes must be String) Create a constructor that accepts first name and last name to create a student object. Create appropriate getters and setters Create another class StudentOperationClient, that contains a main program. This is the place where the student objects are created and other activities are performed. In the main program, create student objects, with the following first and last names. Chris...
Program in Java Create a class and name it MyArray and implement following method. * NOTE:...
Program in Java Create a class and name it MyArray and implement following method. * NOTE: if you need more methods, including insert(), display(), etc. you can also implement those. Method name: getKthMin(int k) This method receives an integer k and returns k-th minimum value stored in the array. * NOTE: Items in the array are not sorted. If you need to sort them, you can implement any desired sorting algorithm (Do not use Java's default sorting methods). Example: Items...
Program in Java Create a class and name it MyArray and implement following method. * NOTE:...
Program in Java Create a class and name it MyArray and implement following method. * NOTE: if you need more methods, including insert(), display(), etc. you can also implement those. Method name: getKthMin(int k) This method receives an integer k and returns k-th minimum value stored in the array. * NOTE: Items in the array are not sorted. If you need to sort them, you can implement any desired sorting algorithm (Do not use Java's default sorting methods). Example: Items...
10) Create a java program that will ask for name and age with method age where...
10) Create a java program that will ask for name and age with method age where it will check the condition that id you are greater than 18 you can vote.
write program in java Create a class named PersonalDetails with the fields name and address. The...
write program in java Create a class named PersonalDetails with the fields name and address. The class should have a parameterized constructor and get method for each field.  Create a class named Student with the fields ID, PersonalDetails object, major and GPA. The class should have a parameterized constructor and get method for each field. Create an application/class named StudentApp that declare Student object. Prompts (GUI input) the user for student details including ID, name, address, major and GPA....
Create a program in Java for storing the personal information of students and teachers of a...
Create a program in Java for storing the personal information of students and teachers of a school in a .csv (comma-separated values) file. The program gets the personal information of individuals from the console and must store it in different rows of the output .csv file. Input Format User enters personal information of n students and teachers using the console in the following format: n Position1 Name1 StudentID1 TeacherID1 Phone1 Position2 Name2 StudentID2 TeacherID2 Phone2 Position3 Name3 StudentID3 TeacherID3 Phone3...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT