Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Formatter;
- public class party_friends
- {
- public static void main(String arg[])
- {
- Scanner friends = new Scanner(System.in);
- System.out.println("Enter the Numbers to take to a Party: ");
- int total_Friends = friends.nextInt();
- String friends_Name[] = new String[total_Friends];
- String friends_hobbies[] = new String[total_Friends];
- int friends_age[] = new int[total_Friends];
- for (int i = 0; i< friends_Name.length; i++)
- {
- Scanner input = new Scanner(System.in);
- System.out.println("\nEnter Your Friend's Name and Hobby(in that order) : ");
- friends_Name[i] = input.nextLine();
- friends_hobbies[i] = input.nextLine();
- //int friends_age[] = new int[total_Friends];
- boolean is_Of_Age = false;
- while(!is_Of_Age)
- {
- Scanner Age = new Scanner(System.in);
- System.out.println("Enter Your Friend's Age: ");
- friends_age[i] = Age.nextInt();
- if(friends_age[i] >= 21)
- {
- is_Of_Age = true;
- }
- }
- //friend[i] = input.nextLine();
- //System.out.println(friend[0]);
- //System.out.format("%1s%16s%10d", name , hobby, age);
- //System.out.println("Name " + name + "\nHobby: " + hobby + "\nAge: " + age);
- }
- System.out.println("Index \tName \t\t\tHobby \t\tAge");
- for(int i = 0; i < friends_Name.length; i++)
- {
- System.out.println(i +"\t\t"+ friends_Name[i] +"\t\t"+ friends_hobbies[i] +"\t\t"+ friends_age[i]);
- //System.out.format("%1s%16s%10d" , friends_Name[i] +" "+ friends_hobbies[i] +" "+ friends_age[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement