Answered step by step
Verified Expert Solution
Link Copied!

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??
program2Main.java
package daway.s;
public class program2Main
{
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
// Create an instance of the Student class
Student myStudent = new Student();
// Request information from the user
System.out.print("Please enter your first name: ");
String fName = scanner.nextLine();
System.out.print("Please enter your last name: ");
String lName = scanner.nextLine();
System.out.print("Please enter your id number: ");
String id = scanner.nextLine();
System.out.print("Please enter your major: ");
String m = scanner.nextLine();
// Set the values using set methods
myStudent.setFirstName(fName);
myStudent.setLastName(lName);
myStudent.setIdNumber(id);
myStudent.setMajor(m);
// Display the student's information
System.out.println("
Student Information:");
System.out.println("First Name: "+ myStudent.getFirstName());
System.out.println("Last Name: "+ myStudent.getLastName());
System.out.println("ID Number: "+ myStudent.getIdNumber());
System.out.println("Major: "+ 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 setFirstName(String fName){
this.firstName = fName;
}
public void setLastName(String IName){
this.lastName = IName;
}
public void setIdNumber(String id){
this.idNumber = id;
}
public void setMajor(String 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;
}
}
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Issues In Database Management A Refernce For The Thinking Practitioner

Authors: Fabian Pascal

1st Edition

0201485559, 978-0201485554

More Books

Students also viewed these Databases questions

Question

2. Employees and managers participate in development of the system.

Answered: 1 week ago