-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleBot.java
More file actions
46 lines (35 loc) · 1.75 KB
/
Copy pathSimpleBot.java
File metadata and controls
46 lines (35 loc) · 1.75 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
import java.util.Scanner;
public class SimpleBot {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Hello! My name is Chatty Bot.");
System.out.println("I was created in 2021.");
System.out.println("Please, remind me of your name.");
String name = scanner.nextLine();
System.out.println("What a great name you have, " + name + "!");
System.out.println("Let me guess your age.");
System.out.println("Enter remainders of dividing your age by 3, 5 and 7.");
int rem3 = scanner.nextInt();
int rem5 = scanner.nextInt();
int rem7 = scanner.nextInt();
int age = (rem3 * 70 + rem5 * 21 + rem7 * 15) % 105;
System.out.println("Your age is " + age + "; that's a good time to start programming!");
System.out.println("Now I will prove to you that I can count to any number you want.");
int userInput = scanner.nextInt();
for (int i = 0; i <= userInput; i++) {
System.out.println(i + "!");
}
System.out.println("Let's test your programming knowledge.");
System.out.println("Why do we use methods?");
System.out.println("1. To repeat a statement multiple times.");
System.out.println("2. To decompose a program into several small subroutines.");
System.out.println("3. To determine the execution time of a program.");
System.out.println("4. To interrupt the execution of a program.");
int answer = scanner.nextInt();
while (answer != 2) {
System.out.println("Please try again.");
answer = scanner.nextInt();
}
System.out.println("Completed, have a nice day!");
}
}