Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE FOLLOW THE CODE AS IT IS JAVA JAVA 13.15 Lab: Simple Arrays Analyzing People's Weights Start with the provided template code. Test 1: Using

PLEASE FOLLOW THE CODE AS IT IS

JAVA JAVA

13.15 Lab: Simple Arrays

Analyzing People's Weights

Start with the provided template code.

Test 1: Using a loop, prompt the user to enter five numbers, that are five people's weights. Store the numbers in an array of doubles. Then use another loop to output the array's numbers on one line, with each number followed by one space. Example:

Enter weight 1: 96.6 Enter weight 2: 212.2 Enter weight 3: 150.5 Enter weight 4: 120.1 Enter weight 5: 175 You entered weights: 96.6 212.2 150.5 120.1 175.0 

Test 2: Add code to loop and summing the array's elements to compute the total weight. Output the result rounded to 2 decimal places with the last digit in column 24.

Test 3: Add code to compute and output the average of the array's elements, rounded to 2 decimal places, lined up on the decimal with the total.

Tests 4 - 6: Add a method definition for a method to find and return the smallest weight in the array. The array will be passed into the method as a parameter.

Call the method and then display the returned value, rounded to 2 decimal places, lined up on the decimal with the total and average.

Example:

Enter weight 1: 96.6 Enter weight 2: 212.2 Enter weight 3: 150.5 Enter weight 4: 120.1 Enter weight 5: 175 You entered weights: 96.6 212.2 150.5 120.1 175.0 Total weight: 754.40 Average weight: 150.88 Min weight: 96.60

import java.util.Scanner;

public class WeightAnalysis { final static int NUM_WEIGHTS = 5;

public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); /* Add main method code here. */ return; } /* Add method definition here */ }

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

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions

Question

LO23.3 Demonstrate how income inequality has changed since 1975.

Answered: 1 week ago

Question

Define organisational jargon.

Answered: 1 week ago