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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:30
One subtask in the game is to roll the dice. explain why is roll the dice an abstraction.
Answers: 3
question
Computers and Technology, 22.06.2019 21:00
Ulia is planning to attend the same private four-year college her parents attended. she wants to save at least $18,000 in four years to contribute to her college education. which monthly deposit amounts can julia use to achieve her goal? check all that apply.
Answers: 2
question
Computers and Technology, 23.06.2019 17:30
Write pseudocode to represent the logic of a program that allows the user to enter a value. the program multiplies the value by 10 and outputs the result.
Answers: 1
question
Computers and Technology, 24.06.2019 16:30
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
question
Mathematics, 10.12.2019 01:31
question
Mathematics, 10.12.2019 01:31
Questions on the website: 13722361