Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- so i gotta write a program to read in names, ages, and phone numbers for ten people; group the data into a class and create an array to store the info. any suggestions?
- */
- public class Person(){
- private String name;
- private int age;
- private String phone;//remember you want to interpet the phone as a string
- public Person(String n, int a, String p){
- name = s;
- age = a;
- phone = p;
- }
- }
- public class workingClass(){
- public static void main(String[] args){
- Scanner in = new Scanner(System.in);
- int numberOfTimes = 10;
- Person[] people = new Person[numberOfTimes];
- for(int i = 0; i < numberOfTimes; i++}(
- String name ="", phone="";
- int age=0;
- System.out.println("enter a name");
- name = in.nextLine();
- System.out.println("enter age");
- age= in.nextInt();
- System.out.println("enter phone");
- phone= in.nextLine();
- people[i] = new Person(name, age, phone);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement