/
tasmity
/
Chatty_Bot
Обзор
Документация
Войти
/
tasmity
/
Chatty_Bot
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/bot/SimpleBot.java
62 строки
2 KB
tasmity@gmail.com
add chat_bot
06 июл 2021, 20:28
06 июл 2021, 20:28
5066e32
Код
Авторство
О чём код?
package bot; import java.util.Scanner; public class SimpleBot { static Scanner scanner = new Scanner(System.in); // Do not change this line public static void main(String[] args) { // write your code here greet("Aid", "2018"); remindName(); guessAge(); count(); test(); end(); scanner.close(); } static void greet(String assistantName, String birthYear) { System.out.println("Hello! My name is " + assistantName + "."); System.out.println("I was created in " + birthYear + "."); } static void remindName() { System.out.println("Please, remind me your name."); String name = scanner.nextLine(); System.out.println("What a great name you have, " + name + "!"); } static void guessAge() { System.out.println("Let me guess your age."); System.out.println("Enter remainders of dividing your age by 3, 5 and 7."); var rem3 = scanner.nextInt(); var rem5 = scanner.nextInt(); var rem7 = scanner.nextInt(); var age = (rem3 * 70 + rem5 * 21 + rem7 * 15) % 105; System.out.println("Your age is " + age + "; that's a good time to start programming!"); } static void count() { System.out.println("Now I will prove to you that I can count to any number you want."); var num = scanner.nextInt(); for (var i = 0; i <= num; i++) { System.out.printf("%d!%n", i); } } static void test() { 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."); while (scanner.nextInt() != 2) { System.out.println("Please, try again."); } } static void end() { System.out.println("Congratulations, have a nice day!"); // Do not change this text } }