Advertisement
ateyevtm

Untitled

Oct 3rd, 2021
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Praktikum {
  4. public static void main(String[] args) {
  5. System.out.println("Робот-помощник v2.0.");
  6. // Вызовите ниже методы в правильном порядке
  7. sayHello();
  8. sayHelloByTime();
  9. welcomeUserByName();
  10. printCity();
  11. printSuccess();
  12. }
  13.  
  14. public static void welcomeUserByName() {
  15. Scanner scanner = new Scanner(System.in);
  16. System.out.println("Как вас зовут?");
  17. String name = scanner.next();
  18. }
  19.  
  20. public static void printSuccess() {
  21. System.out.println("У вас уже неплохо получается программировать!");
  22. }
  23.  
  24. public static void sayHello(){
  25. System.out.println("Привет!");
  26.  
  27. }
  28. // Допишите метод sayHello(), который печатает: Привет!
  29.  
  30. public static void printCity(){
  31. System.out.println("Из какого вы города?");
  32. Scanner scanner = new Scanner(System.in);
  33. String city = scanner.next();
  34. System.out.println("Рад познакомиться, " + welcomeUserByName(name) + " из " + city + "!");
  35. }// Допишите метод printCity(), который спрашивает: Из какого вы города?
  36.  
  37. public static void sayHelloByTime() {
  38. Scanner scanner = new Scanner(System.in);
  39. System.out.println("Который час?");
  40. int currentHour = scanner.nextInt();
  41. if (currentHour < 6) {
  42. System.out.println("Доброй ночи!");
  43. } else if (currentHour > 22) {
  44. System.out.println("Доброй ночи!");
  45. } else if (currentHour < 12) {
  46. System.out.println("Доброе утро!");
  47. } else if (currentHour < 18) {
  48. System.out.println("Добрый день!");
  49. } else {
  50. System.out.println("Добрый вечер!");
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement