Advertisement
Guest User

Advertisement Message

a guest
Feb 26th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.43 KB | None | 0 0
  1. import java.util.Random;
  2. import java.util.Scanner;
  3.  
  4. public class Obj_Ex_01_AdvertisementMessage {
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.  
  8.         String[] phrases = new String[] {"Excellent product.", "Such a great product.", "I always use that product.",
  9.                 "Best product of its category.", "Exceptional product.", "I can’t live without this product."};
  10.         String[] events = new String[] {"Now I feel good.", "I have succeeded with this product.",
  11.         "Makes miracles. I am happy of the results!", "I cannot believe but now I feel awesome.",
  12.         "Try it yourself, I am very satisfied.", "I feel great!"};
  13.         String[] authors = new String[] {"Diana", "Petya", "Stella", "Elena", "Katya", "Iva", "Annie", "Eva"};
  14.         String[] cities = new String[] {"Burgas", "Sofia", "Plovdiv", "Varna", "Ruse"};
  15.  
  16.         Random random = new Random();
  17.         int n = Integer.parseInt(scanner.nextLine());
  18.  
  19.         for (int i = 0; i < n; i++) {
  20.             String phrase = phrases[random.nextInt(phrases.length)];
  21.             String event = events[random.nextInt(events.length)];
  22.             String name = authors[random.nextInt(authors.length)];
  23.             String city = cities[random.nextInt(cities.length)];
  24.             String result = String.format("%s %s %s - %s", phrase, event, name,city);
  25.             System.out.println(result);
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement