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 dimensional D ragged array that stores the dog types for each household in your family. In a method called setOwnersAndDogs, create a D 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 types for each household. Return the D 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 ArraysVjava. 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 wordwrap
SAMPLE OUTPUT
Enter the number of dog owners in your family by household yours grandparents, etc.:
Enter the number of dogs for household # in your family:
Enter the number of dogs for household # in your family:
Enter dog type for family household : golden retriever
Enter dog type for family household : beagle
Enter dog type for family household : chow
Enter dog type for family household : siberian husky
Enter dog type for family household : pomsky
DOG TYPES IN MY FAMILY
Family Household:
Dog Type : GOLDEN RETRIEVER
Dog Type : BEAGLE
Family Household:
Dog Type : CHOW
Dog Type : SIBERIAN HUSKY
Dog Type : POMSKY
Import statement.
Class header
Declare input object as field.
Header for main.
Call setOwnersAndDogs method in same declaration statement as D myFamDogs array.
Print "DOG TYPES IN MY FAMILY".
for header using i from until length of rows in array.
Print "Family Household: where is etc.
for header using j from until length of columns in each row of array.
Print "Dog Type : XXXXXXXXXX where is 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 D 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 until noOwners
Prompt "Enter the number of dogs for household # in your family: where is etc.
Read noDogs.
Clear input buffer.
Assign noDogs to each row in the array.
END for
for i from until length of rows in array.
for j from until length of columns in each row of array.
Prompt "Enter dog type for family household : where s are 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
