Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/************************************************************** MaggiePetStore Program: The program gets various information about three pets in Maggie's pet store from the key board, and then outputs some of the

/************************************************************** MaggiePetStore Program: The program gets various information about three pets in Maggie's pet store from the key board, and then outputs some of the notable pets' information to the console. The information you'll be getting is as follows: The name of each pet (collected in an array of strings) How old each pet is (collected in an array of ints) Each pet's weight (collected in an array of doubles) After getting all that information, your program should output the following: The age of the youngest pet The weight of the heaviest pet **************************************************************/ import java.util.Scanner; public class Lab11 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); //create three arrays for names, ages, and weights final int SIZE = 3; String[] petNames = new String[SIZE]; int[] petAges = new int[3]; double[] petWeights = new double[SIZE]; System.out.println("Welcome to Maggie\'s Pet Shop Management Software!"); System.out.println("-------------------------------------------------"); //the following three methods will ask a user to enter //names, ages, and weights //respectively, and store their input into the arrays. getPetNames(petNames, scan); getPetAges(petAges, scan); getPetWeights(petWeights, scan); //the following two methods compute the youngest pet and //the heaviest pet, //and return their index. int youngestIndex = findYougestPet(petAges); int heaviestIndex = findHeaviestPet(petWeights); //print out the results System.out.println(" The youngest pet in Maggie\'s shop is " + petNames[youngestIndex] + ", who is only " + petAges[youngestIndex] + " year old."); System.out.println("The heaviest pet in Maggie\'s shop is " + petNames[heaviestIndex] + ", whose weight is " + petWeights[heaviestIndex] + " pounds."); } public static void getPetNames(String[] petNames, Scanner scan) { //TO BE COMPLETED } public static void getPetAges(int[] petAges, Scanner scan) { //TO BE COMPLETED } public static void getPetWeights(double[] petWeights, Scanner scan) { //TO BE COMPLETED } public static int findYougestPet(int[] petAges) { //TO BE COMPLETED } public static int findHeaviestPet(double[] petWeights) { //TO BE COMPLETED } } 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

LO1.2 Describe the role of economic theory in economics.

Answered: 1 week ago