Question: Instructions: Code a 2 - dimensional ( 2 D ) ragged array that stores the dog types for each household in your family. In a

Instructions: Code a 2-dimensional (2D) ragged array that stores the dog types for each household in your family. In a method called setOwnersAndDogs, create a 2D null array. Prompt for the number of households in your family that owns dogs; then, prompt for the number of dogs per household. Use these values to give the array dimension by household and dogs per household. Once the array is created, prompt for the dog type(s) for each household. Return the 2D array. In the main(), call setOwnersAndDogs(). Print the title of the final output with double line advances at the beginning and single at the end. Print the dog types for each household. Save the program as ArraysV3.java. Which one is the row and which one is the column? Hint: For every owner or household there are x number of dogs. For the final output single line advance at the beginning and at the end of the line for "Family Household", but only at the beginning of the line for "Dog Type". All lines displayed are on a single line (no word-wrap).
****SAMPLE OUTPUT****
Enter the number of dog owners in your family by household (yours, grandparents, etc.):2
Enter the number of dogs for household #1 in your family:2
Enter the number of dogs for household #2 in your family:3
Enter dog type 1 for family household 1: golden retriever
Enter dog type 2 for family household 1: beagle
Enter dog type 1 for family household 2: chow
Enter dog type 2 for family household 2: siberian husky
Enter dog type 3 for family household 2: pomsky
DOG TYPES IN MY FAMILY
Family Household:1
Dog Type 1: GOLDEN RETRIEVER
Dog Type 2: BEAGLE
Family Household:2
Dog Type 1: CHOW
Dog Type 2: SIBERIAN HUSKY
Dog Type 3: POMSKY
//Import statement.
//Class header
{
//Declare input object as field.
//Header for main.
{
//Call setOwnersAndDogs method in same declaration statement as 2D myFamDogs array.
//Print "DOG TYPES IN MY FAMILY".
//for header using i from 0 until length of rows in array.
{
//Print "Family Household: 9" where 9 is 1,2,3, etc.
//for header using j from 0 until length of columns in each row of array.
{
//Print "Dog Type 9: XXXXXXXXXX" where 9 is 1,2,3, etc. and Xs is the breed.
}//END nested for
//Call println without an argument.
}//END for
//Exit without error.
}//END main
//Header for setOwnersAndDogs.
{
//Partial declaration of ownersDogs 2D array.
//Declare and initialize noOwners.
//Declare and initialize noDogs.
//Prompt "Enter the number of dog owners in your family by household (yours, grandparents, etc.): ".
//Read noOwners.
//Clear input buffer.
//Assign noOwners to the array.
//for owners from 0 until noOwners
{
//Prompt "Enter the number of dogs for household #9 in your family: " where 9 is 1,2,3, etc.
//Read noDogs.
//Clear input buffer.
//Assign noDogs to each row in the array.
}//END for
//for i from 0 until length of rows in array.
{
//for j from 0 until length of columns in each row of array.
{
//Prompt "Enter dog type 9 for family household 9: " where 9s are 1,2,3, etc.
//Read dog type into array.
}//END for
}//END for
//Return the array.
}//END method
}//END APPLICATION CLASS

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!