Bangeev

Untitled

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