Question
Write a Java program that shows a 2-D array of friends where each element taking a value of either 1 or 0 representing whether the
Write a Java program that shows a 2-D array of friends where each element taking a value of either 1 or 0 representing whether the person at row i is friends with person at column j. Your program should also output the number of friends each person has.
Procedure:
1. Ask the user to enter the total number of people in the network to
create the 2-D array (There should be at least 1 person in the network).
2. Store their names in a separate array
3. We will decide whether one person is friends with another if their
names' lexicographic difference is not greater than 12
4. Populate the 2-D array with 1 representing row i and column j being
friends and 0 representing row i and column j not being friends
5. You should assume that you are not friends with yourself, which means
that ArrayOfFriends[i][j] = 0, where i = j
6. Output the 2-D array to the screen (use only tabs for spacing)
7. Also output the total number of friends each person has (calculate using the 2-D Array).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started