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] + " ");
}
}
}
Answers: 2
Computers and Technology, 23.06.2019 07:30
Write a program that inserts the digits of an integer into an array in originalorderfollowed by reverse order. first, promptthe user to enter a positive integer(> 0). determine the number of digits of the integer. create a dynamically allocated integer arrayof a size twice the number of digits.now insert the digits in original order which will occupy half of the array. then, insert the digits in reverse order.finally, output thedigits in thearray.use at least two functions to organize your program.
Answers: 3
Computers and Technology, 25.06.2019 22:30
If you were working on a mainframe, which of the following operating systems would you most likely be using?
Answers: 1
Computers and Technology, 26.06.2019 08:00
What two armies launched the invasion of normandy
Answers: 1
Computers and Technology, 26.06.2019 14:00
Which term describes the situation wherein a jury fails to reach a unanimous verdict? a occurs when a jury cannot reach a unanimous verdict.
Answers: 1
1) Prompt the user to enter five numbers, being five people's weights. Store the numbers in an array...
Business, 19.05.2021 03:00
Mathematics, 19.05.2021 03:00
Mathematics, 19.05.2021 03:00
Mathematics, 19.05.2021 03:00
History, 19.05.2021 03:00
Mathematics, 19.05.2021 03:00
Mathematics, 19.05.2021 03:00
Health, 19.05.2021 03:00