-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMoreUserInput.java
More file actions
69 lines (57 loc) · 1.97 KB
/
MoreUserInput.java
File metadata and controls
69 lines (57 loc) · 1.97 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
https://programmingbydoing.com/a/more-user-input-of-data.html
Ask the user for several pieces of information, and display them on the screen afterward as a summary.
first name
last name
grade (classification)
student id number
login name
GPA (0.0 to 4.0)
You must use the most appropriate type for each variable and not just Strings for everything.
*/
import java.util.*;
class MoreUserInput {
public static void getName(String firstName, String lastName){
System.out.println("\tName: " + lastName + ", " + firstName);
}
public static void getGrade(int grade){
System.out.println("\tGrade: " + grade);
}
public static void getStudentId(int studentId){
System.out.println("\tID: " + studentId);
}
public static void getLoginName(String loginName){
System.out.println("\tLogin: " + loginName);
}
public static void getGpa(double gpa){
System.out.println("\tGPA: " + gpa);
}
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
String firstName;
String lastName;
int grade;
int studentId;
String loginName;
double gpa;
System.out.println("Please enter the following information so I can sell it for a profit!");
System.out.print("First name: ");
firstName = keyboard.next();
System.out.print("Last name: ");
lastName = keyboard.next();
System.out.print("Grade (9-12): ");
grade = keyboard.nextInt();
System.out.print("Student ID: ");
studentId = keyboard.nextInt();
System.out.print("Login: ");
loginName = keyboard.next();
System.out.print("GPA (0.0-4.0): ");
gpa = keyboard.nextDouble();
System.out.println("Your information:");
getName(firstName, lastName);
getGrade(grade);
getStudentId(studentId);
getLoginName(loginName);
getGpa(gpa);
}
}