Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.Scanner; class Student { private int ID; private String First; private String Last; public Student ( int ID , String First, String Last )

import java.util.Scanner;
class Student {
private int ID;
private String First;
private String Last;
public Student(int ID, String First, String Last){
this.ID = ID;
this.First = First;
this.Last = Last;
}
public String printStudent(){
return "ID: "+ ID +"
First Name: "+ First +"
Last Name: "+ Last;
}
}
public class TestStudent {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
System.out.println("Program Title");
System.out.print("Enter the number of students: ");
int n = scanner.nextInt();
scanner.nextLine(); // consume newline
Student[] students = new Student[n];
for (int i =0; i < n; i++){
System.out.println("Enter details for Student "+(i +1)+":");
System.out.print("ID: ");
int id = scanner.nextInt();
scanner.nextLine(); // consume newline
System.out.print("First Name: ");
String firstName = scanner.nextLine();
System.out.print("Last Name: ");
String lastName = scanner.nextLine();
students[i]= new Student(id, firstName, lastName);
}
System.out.println("
Student Records:");
for (int i =0; i < n; i++){
System.out.println("Student "+(i +1)+":
"+ students[i].printStudent());
}
}
}
table of identifers

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

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions