Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.53 KB | None | 0 0
  1. package objects.and.classes.excercise;
  2.  
  3. import java.util.Random;
  4. import java.util.Scanner;
  5.  
  6. public class AdvertisementMessage {
  7.     public static void main(String[] args) {
  8.         Scanner scan = new Scanner(System.in);
  9.        
  10.         int n = Integer.parseInt(scan.nextLine());
  11.        
  12.         String[] phrases = {"Excellent product.",
  13.                             "Such a great product.",
  14.                             "I always use that product.",
  15.                             "Best product of its category.",
  16.                             "Exceptional product.",
  17.                             "I can’t live without this product."};
  18.        
  19.         String[] events = {"Now I feel good.",
  20.                            "I have succeeded with this product.",
  21.                            "Makes miracles. I am happy of the results!",
  22.                            "I cannot believe but now I feel awesome.",
  23.                            "Try it yourself, I am very satisfied.",
  24.                            "I feel great!"};
  25.        
  26.         String[] authors = {"Diana", "Petya","Stella", "Elena",
  27.                              "Katya", "Iva","Annie", "Eva"};
  28.        
  29.         String[] cities = {"Burgas","Sofia", "Plovdiv", "Varna", "Ruse"};
  30.        
  31.         Random rnd = new Random();
  32.        
  33.         for (int i = 0; i < n; i++) {
  34.             int rndPhrase = rnd.nextInt(phrases.length);
  35.             int rndEvent = rnd.nextInt(events.length);
  36.             int rndAuthor = rnd.nextInt(authors.length);
  37.             int rndCity = rnd.nextInt(cities.length);
  38.            
  39.             String phrase = phrases[rndPhrase];
  40.             String event = events[rndEvent];
  41.             String author = authors[rndAuthor];
  42.             String city = cities[rndCity];
  43.            
  44.             System.out.printf("%s %s %s - %s%n",phrase,event,author,city);
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement