forked from AllenDowney/ThinkJavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPetNames.java
More file actions
35 lines (29 loc) · 830 Bytes
/
PetNames.java
File metadata and controls
35 lines (29 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.util.Scanner;
public class PetNames
{
public static void receivePetNames()
{
Scanner in = new Scanner(System.in);
int numPets;
System.out.println("How many pets do you have?");
numPets = in.nextInt();
in.nextLine();
String[] petsArray = new String[numPets];
for (int i = 0; i < petsArray.length; i++)
{
System.out.println("Pet Name: ");
petsArray[i] = in.nextLine();
}
System.out.println("************");
System.out.println("*Pets Names*");
System.out.println("************");
for (int i = 0; i < petsArray.length; i++)
{
System.out.println(petsArray[i]);
}
}
public static void main(String[] args)
{
receivePetNames();
}
}