-
Notifications
You must be signed in to change notification settings - Fork 65
/
Program6.java
51 lines (43 loc) · 1.28 KB
/
Program6.java
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
Learning outcome
how to get user input
Read a byte - nextByte()
Read a short - nextShort()
Read an int - nextInt()
Read a long - nextLong()
Read a float - nextFloat()
Read a double - nextDouble()
Read a boolean - nextBoolean()
Read a complete line - nextLine()
Read a word - next()
*/
import java.util.Scanner;
public class Program6 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
// declaring variables for a student
String name;
int id, age;
double gpa;
boolean isRegisted;
// getting inputs for a student
System.out.print("Enter student name: ");
name = input.nextLine();
System.out.print("Enter student id: ");
id = input.nextInt();
System.out.print("Enter student age: ");
age = input.nextInt();
System.out.print("Enter student gpa: ");
gpa = input.nextDouble();
System.out.print("Enter student is isregistered? true/false : ");
isRegisted = input.nextBoolean();
// printing variables
System.out.println("Student Information");
System.out.println("--------------------");
System.out.println("Name: "+name);
System.out.println("ID: "+id);
System.out.println("Age: "+age);
System.out.println("GPA: "+gpa);
System.out.println("Registered: "+isRegisted);
}
}