-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudent.java
More file actions
34 lines (27 loc) · 1006 Bytes
/
student.java
File metadata and controls
34 lines (27 loc) · 1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package project;
import java.util.Scanner;
public class student {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String name;
int age;
String grade;
System.out.print("Enter student's name: ");
name = scanner.nextLine();
System.out.print("Enter student's age: ");
while (!scanner.hasNextInt()) {
System.out.println("Invalid input. Please enter a valid age.");
scanner.next();
System.out.print("Enter student's age: ");
}
age = scanner.nextInt();
scanner.nextLine();
System.out.print("Enter student's grade: ");
grade = scanner.nextLine();
System.out.println("\nStudent Details:");
System.out.println("Name: " + name);
System.out.println("Age: " + age);
System.out.println("Grade: " + grade);
scanner.close();
}
}