PROGRAM in JAVA Write a program that defines two arrays - one of strings and one of integers, both of size 10. Your program should then ask the user to enter the a string representing a persons name (just one name - their family name - not their given name as well), and an integer representing their age. It should continue to do this until either the user enters ‘done’ instead of a name, or until the array is full (that is, 10 pairs of names and ages have been entered). It should then print out the names and ages as well as the names of the youngest and oldest. Hints: One tricky (deliberately) part is making sure that once you’ve typed ‘done’ to finish entering names, your program does not then ask you for the age of the person with name ‘done’ - be careful about this. This is one of the few cases where, if you are careful, you can sensibly use a ‘break’ statement outside of a switch statement
PROGRAM in JAVA
Write a program that defines two arrays - one of strings and one of integers, both of size 10. Your program should then ask the user to enter the a string representing a persons name (just one name - their family name - not their given name as well), and an integer representing their age. It should continue to do this until either the user enters ‘done’ instead of a name, or until the array is full (that is, 10 pairs of names and ages have been entered). It should then print out the names and ages as well as the names of the youngest and oldest.
Hints: One tricky (deliberately) part is making sure that once you’ve typed ‘done’ to finish entering names, your program does not then ask you for the age of the person with name ‘done’ - be careful about this. This is one of the few cases where, if you are careful, you can sensibly use a ‘break’ statement outside of a switch statement
Stage 6: Assessed Task
Redo Stage 5 above but replace the arrays with ArrayLists.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images