Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hello, What am I doing wrong here?? program 2 Main.java package daway.s; public class program 2 Main { public static void main ( String [
Hello, What am I doing wrong here??
programMain.java
package daway.s;
public class programMain
public static void mainString args
Scanner scanner new ScannerSystemin;
Create an instance of the Student class
Student myStudent new Student;
Request information from the user
System.out.printPlease enter your first name: ;
String fName scanner.nextLine;
System.out.printPlease enter your last name: ;
String lName scanner.nextLine;
System.out.printPlease enter your id number: ;
String id scanner.nextLine;
System.out.printPlease enter your major: ;
String m scanner.nextLine;
Set the values using set methods
myStudent.setFirstNamefName;
myStudent.setLastNamelName;
myStudent.setIdNumberid;
myStudent.setMajorm;
Display the student's information
System.out.println
Student Information:";
System.out.printlnFirst Name: myStudent.getFirstName;
System.out.printlnLast Name: myStudent.getLastName;
System.out.printlnID Number: myStudent.getIdNumber;
System.out.printlnMajor: myStudent.getMajor;
Close the scanner
scanner.close;
Student.java
package daway.s;
import java.util.Scanner;
public class Student
private String firstName;
private String lastName;
private String idNumber;
private String major;
Set methods
public void setFirstNameString fName
this.firstName fName;
public void setLastNameString IName
this.lastName IName;
public void setIdNumberString id
this.idNumber id;
public void setMajorString m
this.major m;
Get methods
public String getFirstName
return firstName;
public String getLastName
return lastName;
public String getIdNumber
return idNumber;
public String getMajor
return major;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started