Advertisement
An0n0ym0usHacker

Friends

Feb 16th, 2020
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.02 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4.  
  5.  
  6. public class DataFriends {
  7.  
  8.     static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  9.  
  10.     public static void main(String[] args) throws  IOException {
  11.  
  12.         System.out.println("Enter the Numbers to take to a Party: ");
  13.         int total_Friends = Integer.parseInt(br.readLine());
  14.  
  15.         String friends_Name[] = new String[total_Friends];
  16.         String friends_hobbies[] = new String[total_Friends];
  17.         int friends_age[] = new int[total_Friends];
  18.         int sum = 0;
  19.         float average;
  20.         for (int i = 0; i< friends_Name.length; i++)
  21.         {
  22.  
  23.             System.out.println("\nEnter Your Friend's Name : ");
  24.             friends_Name[i] = br.readLine();
  25.             System.out.println("Enter Your Friend's Hobby: ");
  26.             friends_hobbies[i] = br.readLine();
  27.  
  28.             int trials = 1;
  29.             for(int j = 0; j < trials; j++)
  30.             {
  31.                 System.out.println("Enter Your Friend's Age: ");
  32.                 int age =Integer.parseInt(br.readLine());
  33.                 if(age >= 21)
  34.                 {
  35.                     friends_age[i] = age;
  36.  
  37.                     break;
  38.                 }else {
  39.                     trials++;
  40.  
  41.                 }
  42.             }
  43.  
  44.         }
  45.  
  46.         System.out.println(String.format("%50s", "FULL TABLE\n"));
  47.         System.out.println(String.format("%15s %20s %10s %20s %10s %20s", "Name", "|", "Hobby", "|", "Age", "|"));
  48.         System.out.println(String.format("%s", "___________________________________________________________________________________________________"));
  49.  
  50.         for(int i = 0; i < friends_Name.length; i++)
  51.         {
  52.             System.out.println(String.format("%15s %20s %10s %20s %10s %20s" , friends_Name[i], "|", friends_hobbies[i], "|", friends_age[i], "|"));
  53.  
  54.         }
  55.  
  56.         //int age = friends_age[i];
  57.         boolean done = false;
  58.         System.out.println(String.format("\n\n%50s", "FRIENDS OLDER THAN 25\n"));
  59.         System.out.println(String.format("%15s %20s %10s %20s %10s %20s", "Name", "|", "Hobby", "|", "Age", "|"));
  60.         System.out.println(String.format("%s", "___________________________________________________________________________________________________"));
  61.         boolean above25;
  62.         int i;
  63.         do {
  64.             above25 = false;
  65.             for (i = 0; i < friends_Name.length; i++) {
  66.                 while (!above25) {
  67.                     if (friends_age[i] > 25) {
  68.                         above25 = true;
  69.                         System.out.println(String.format("%15s %20s %10s %20s %10s %20s", friends_Name[i], "|", friends_hobbies[i], "|", friends_age[i], "|"));
  70.                         //above25 = true;
  71.                     } else {
  72.                         System.out.println("None of My Friends are Older Than 25");
  73.                         break;
  74.                     }
  75.                 }
  76.             }
  77.  
  78.         } while (above25 = false);
  79.  
  80.     }
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement