subject
Computers and Technology, 03.08.2021 02:40 tankddd

1) Prompt the user to enter five numbers, being five people's weights. Store the numbers in an array of doubles. Output the array's numbers on one line, each number followed by one space. (2 pts) Ex:
Enter weight 1: 236
Enter weight 2: 89.5
Enter weight 3: 142
Enter weight 4: 166.3
Enter weight 5: 93
You entered: 236.0 89.5 142.0 166.3 93.0
(2) Also output the total weight, by summing the array's elements. (1 pt)
(3) Also output the average of the array's elements. (1 pt)
(4) Also output the max array element. (2 pts)
Ex:
Enter weight 1: 236
Enter weight 2: 89.5
Enter weight 3: 142
Enter weight 4: 166.3
Enter weight 5: 93
You entered: 236.0 89.5 142.0 166.3 93.0
Total weight: 726.8
Average weight: 145.35999999999999
Max weight: 236.0

I attempted this but kept getting errors:
import java. util. Scanner;
public class PeopleWeights{
public static void main(String[] args) {
Scanner input = new Scanner(System. in);
int SIZE = 5;
double[] array = new double[5];
// read 5 inputs from user
for (int i = 0; i < SIZE; i++) {
System. out. print("Enter weight ");
array[i] = input. nextDouble();
}
// display the data
System. out. print("You entered: ");
for (int i = 0; i < SIZE; i++) {
System. out. print(array[i] + " ");
}
}
}

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 12:30, umimgoingtofail
What is the difference between the internet and the world wide web?
Answers: 1
image
Computers and Technology, 23.06.2019 18:00, larry5007
Freya realizes she does not have enough in her bank account to use the debit card. she decides to use a credit card instead. which questions should freya answer before using a credit card? check all that apply. can i pay at least the minimum payment each month? can i make payments on time and avoid late fees? will i have to take out a loan? how much in finance charges can i afford to pay? should i talk to a consumer credit counseling service?
Answers: 1
image
Computers and Technology, 23.06.2019 21:10, jmolina57
Asample of 200 rom computer chips was selected on each of 30 consecutive days, and the number of nonconforming chips on each day was as follows: 8, 19, 27, 17, 38, 18, 4, 27, 9, 22, 30, 17, 14, 23, 15, 14, 12, 20, 13, 18, 14, 20, 9, 27, 30, 13, 10, 19, 12, 26. construct a p chart and examine it for any out-of-control points. (round your answers to four decimal places.)
Answers: 2
image
Computers and Technology, 24.06.2019 16:30, kjhgfcvb5761
The database design steps are listed below in the incorrect order. choose the correct order number next to each step. determine the information to be stored in the database. determine the fields needed to record the data determine if there will be any repetition of data entered, and separate the fields into tables to normalize the data. create relationships to connect the tables.
Answers: 3
You know the right answer?
1) Prompt the user to enter five numbers, being five people's weights. Store the numbers in an array...

Questions in other subjects:

Konu
Mathematics, 02.03.2021 14:00
Konu
Mathematics, 02.03.2021 14:00