0% found this document useful (0 votes)
7 views1 page

import java

The document contains a Java class named StudentUtil that provides methods for gathering and displaying information about students. It allows the user to input the number of students, their names, surnames, and ages, and then prints this information. The class utilizes the Scanner class for user input and stores student data in an array of Student objects.

Uploaded by

den
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

import java

The document contains a Java class named StudentUtil that provides methods for gathering and displaying information about students. It allows the user to input the number of students, their names, surnames, and ages, and then prints this information. The class utilizes the Scanner class for user input and stores student data in an array of Student objects.

Uploaded by

den
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

import java.util.

Scanner;

public class StudentUtil {


public static Student[] getInfo() {
System.out.println("How many students do you want to include in?");
int count = new Scanner(System.in).nextInt();
Student[] students = new Student[count];
for(int i=0;i<count;i++) {
students[i] = studentMethod();
}
return students;
}

public static void chapEt(Student[] students) {


for(int i=0;i< students.length;i++) {
System.out.println(students[i].name);
System.out.println(students[i].surname);
System.out.println(students[i].age);
System.out.println("----------");
}
}

public static Student studentMethod() {


Student a = new Student();
System.out.println("Enter a name");
a.name = new Scanner(System.in).nextLine();
System.out.println("Enter a surname");
a.surname = new Scanner(System.in).nextLine();
System.out.println("Enter age");
a.age = new Scanner(System.in).nextInt();
return a;
}
}

You might also like