Question: Why is this not executing the fieldValues() method I call more than once...here is my code and sample output in Java Eclipse import java.util.Scanner; public

Why is this not executing the fieldValues() method I call more than once...here is my code and sample output in Java EclipseWhy is this not executing the fieldValues() method I call more than

import java.util.Scanner;

public class studentmain {

private static Scanner input;

public static void main(String[] args) {

input = new Scanner(System.in);

student Michael = new student();

student Gabriel = new student();

System.out.printf("name: ");

Michael.setName(input.nextLine());

System.out.printf("Id: ");

Michael.setId(input.nextInt());

System.out.printf("GPA: ");

Michael.setGpa(input.nextDouble());

Michael.fieldValues();

System.out.printf("name: ");

Gabriel.setName(input.nextLine());

System.out.printf("Id: ");

Gabriel.setId(input.nextInt());

System.out.printf("GPA: ");

Gabriel.setGpa(input.nextDouble());

Gabriel.fieldValues();

}

}

public class student {

private String name;

private double gpa;

private int id;

public student() {

}

public student(String Name) {

name = Name;

}

public student(String Name, double Gpa) {

name = Name;

gpa = Gpa;

}

public String getName() {

return name;

}

public void setName(String Name) {

name = Name;

}

public double getGpa() {

return gpa;

}

public void setGpa(double gpA) {

gpa = gpA;

}

public int getId() {

return id;

}

public void setId(int iD) {

id = iD;

}

public void fieldValues() {

System.out.printf("name is: %s ", getName());

System.out.printf("Id is: %d ", getId());

System.out.printf("GPA is: %f ", getGpa());

}

}

1 import java.util.Scanner; public class student 3 public class studentmain 4 private static Scanner input; private String name; private double gpa; private int id; 6 public static void main(String[] args) public student) ( input new Scanner(System.in); public student (String Name) name Name student Michael new student); student Gabriel-new student .2 public student (String Name, double Gpa) System.out.printf("name: " Michael.setName(input.nextline)); System.out.printf("Id: ; Michael.setId input.nextInt)) System.out.printf("GPA: Michael.setGpa(input.nextDouble)) name Name; public String getName) return nane; 0 Michael.fieldValues ; public void setName (String Name) name Name; System.out.printf("name:; Gabriel.setName(input.nextline)); System.out.printf("Id: ") Gabriel.setId(input.nextInt)) System.out.printf("GPA: Gabriel.setGpa(input.nextouble(O) c double getpa) return Epa .6 .7 public void setGpa(double EpA) ( Gabriel.fieldValuesO gpa gpA public int getId) ( return id; public void setId(int iD) public void fieldValues ) System.out.printf(" name is: sn", getName)); System.out.printf("Idis: %din, getId()); System . out . printf("GPA is: %fin",lgetGpa()); DConsole Dstudentjava D studentmainjava studentmain (Java Application] C: Program Files Java ire1.8.0 1611binjavaw.exe (Feb 4, 2018, 2:28:02 PM) name: John Id: 0001 GPA: 3.45 ame is John Id is: 1 GPA is : 3.450000 name: Id

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!