-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestlog.java
More file actions
42 lines (31 loc) · 1.15 KB
/
testlog.java
File metadata and controls
42 lines (31 loc) · 1.15 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
package quacktest;
/**
* Created by fattyduck on 3/6/15.
*/
import java.util.Scanner;
public class testlog {
public static void main(String[] args){
Scanner cow= new Scanner(System.in);
System.out.println("Are you a male or female?");
String sex, pass;
sex=cow.next();
if(sex.equals("male")){ //use variable.equals for strings and other non numbers otherwise it will most likely be false
System.out.println("Please enter your age");
}else{
System.out.println("Please visit our sister site for Females");
}
int age = cow.nextInt();
if(age>=18){
System.out.println("Please present password to enter");
}else{
age-=18; //shortcut for age = age -18;
System.out.println("You are too young please come back in " + Math.abs(age) + " years"); //used math.abs() to make sure positive number
}
pass=cow.next();
if(pass.equals ("cowb91")){
System.out.println("You have logged in");
}else{
System.out.println("Password is not correct, please re-enter");
}
}
}