Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. package assistant;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class PersonalAssistant {
  6. final static Scanner scanner = new Scanner(System.in); // Do not change this line
  7.  
  8. public static void main(String[] args) {
  9. greet("Aid", "2018"); // change it as you need
  10. remindName();
  11. guessAge();
  12. count();
  13. val();
  14. end();
  15. }
  16.  
  17. static void greet(String assistantName, String birthYear) {
  18. System.out.println("Hello! My name is " + assistantName + ".");
  19. System.out.println("I was created in " + birthYear + ".");
  20. System.out.println("Please, remind me your name.");
  21. }
  22.  
  23. static void remindName() {
  24. String name = scanner.nextLine();
  25. System.out.println("What a great name you have, " + name + "!");
  26. }
  27.  
  28. static void guessAge() {
  29. System.out.println("Let me guess your age.");
  30. System.out.println("Say me remainders of dividing your age by 3, 5 and 7.");
  31. int rem3 = scanner.nextInt();
  32. int rem5 = scanner.nextInt();
  33. int rem7 = scanner.nextInt();
  34. int age = (rem3 * 70 + rem5 * 21 + rem7 * 15) % 105;
  35. System.out.println("Your age is " + age + "; that's a good time to start programming!");
  36. }
  37.  
  38. static void count() {
  39. System.out.println("Now I will prove to you that I can count to any number you want.");
  40. int num = scanner.nextInt();
  41. for (int i = 0; i <= num; i++) {
  42. System.out.printf("%d!\n", i);
  43. }
  44. }
  45.  
  46. static void val() {
  47. System.out.println("Let's test your programming knowledge.");
  48. // write your code here
  49.  
  50. System.out.println("Do you like java?");
  51. System.out.println("1. No.");
  52. System.out.println("2. Yes.");
  53. System.out.println("3. What is that?");
  54. while (true) {
  55.  
  56. int a = scanner.nextInt();
  57. if (a != 2) {
  58. System.out.println("Please, try again.");
  59.  
  60. } else {
  61.  
  62. break;
  63. }
  64. }
  65.  
  66.  
  67. }
  68.  
  69. static void end() {
  70.  
  71.  
  72. System.out.println("Congratulations, have a nice day!"); // Do not change this text
  73.  
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement