-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathUserInput.java
More file actions
30 lines (23 loc) · 981 Bytes
/
UserInput.java
File metadata and controls
30 lines (23 loc) · 981 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
package org.codedifferently;
import java.util.Scanner;
public class UserInput {
//Prompts for username, via scanner. if argument is false then it prompts for lastName.
public String promptUserName(boolean isFirstName) {
if(isFirstName) System.out.println("Welcome to the Budget Calculator!");
System.out.println((isFirstName) ? "What is your first name?" : "What is your last name?");
Scanner scan = new Scanner(System.in);
return scan.next();
}
//Prompts for user budget, via scanner.
public double promptUserBudget() {
System.out.println("Okay.., what's your budget lookin' like today?:");
Scanner scan = new Scanner(System.in);
return scan.nextDouble();
}
//Prompts for a coupon code, via scanner.
public String promptCouponCode() {
System.out.println("Alrighty.. put in your coupon code:");
Scanner scan = new Scanner(System.in);
return scan.next();
}
}