Computers and Technology
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] + " ");
}
}
}

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 03:30, 890777
In vista and windows 7, the appearance and personalization option allows you to change the
Answers: 1
image
Computers and Technology, 23.06.2019 09:00, 19youngr
Which company provides a crowdsourcing platform for corporate research and development? a: mtruk b: wiki answers c: mediawiki d: innocentive
Answers: 2
image
Computers and Technology, 23.06.2019 16:30, isaiahhuettnerowgg8d
What is one reason why indoor air pollution has become an increasing problem.
Answers: 1
image
Computers and Technology, 24.06.2019 15:30, PresleyPie9452
George is working as a programming team lead. which statements correctly describe the skills that he requires?
Answers: 3
Do you know the correct 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
History, 22.01.2020 03:31
Konu
Biology, 22.01.2020 03:31
Konu
Mathematics, 22.01.2020 03:31