1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
myrzilka [38]
3 years ago
11

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) (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)
Engineering
2 answers:
pochemuha3 years ago
8 0

Answer:

import java.util.Scanner;

  public class PeopleWeights {

    public static void main(String[] args) {

    Scanner reader = new Scanner(System.in);  

    double weightOne = reader.nextDouble();

    System.out.println("Enter 1st weight:");

    double weightTwo = reader.nextDouble();

    System.out.println("Enter 2nd weight :");

    double weightThree = reader.nextDouble();

    System.out.println("Enter 3rd weight :");

    double weightFour = reader.nextDouble();

    System.out.println("Enter 4th weight :");

    double weightFive = reader.nextDouble();

    System.out.println("Enter 5th weight :");

     double sum = weightOne + weightTwo + weightThree + weightFour + weightFive;

     double[] MyArr = new double[5];

     MyArr[0] = weightOne;

     MyArr[1] = weightTwo;

     MyArr[2] = weightThree;

     MyArr[3] = weightFour;

     MyArr[4] = weightFive;

     System.out.printf("You entered: " + "%.1f %.1f %.1f %.1f %.1f ", weightOne, weightTwo, weightThree, weightFour, weightFive);

     double average = sum / 5;

     System.out.println();

     System.out.println();

     System.out.println("Total weight: " + sum);

     System.out.println("Average weight: " + average);

     double max = MyArr[0];

     for (int counter = 1; counter < MyArr.length; counter++){

        if (MyArr[counter] > max){

           max = MyArr[counter];

        }

     }

     System.out.println("Max weight: " + max);

  }

import java.util.Scanner;

  public class PeopleWeights {

    public static void main(String[] args) {

    Scanner reader = new Scanner(System.in);  

    double weightOne = reader.nextDouble();

    System.out.println("Enter 1st weight:");

    double weightTwo = reader.nextDouble();

    System.out.println("Enter 2nd weight :");

    double weightThree = reader.nextDouble();

    System.out.println("Enter 3rd weight :");

    double weightFour = reader.nextDouble();

    System.out.println("Enter 4th weight :");

    double weightFive = reader.nextDouble();

    System.out.println("Enter 5th weight :");

     double sum = weightOne + weightTwo + weightThree + weightFour + weightFive;

     double[] MyArr = new double[5];

     MyArr[0] = weightOne;

     MyArr[1] = weightTwo;

     MyArr[2] = weightThree;

     MyArr[3] = weightFour;

     MyArr[4] = weightFive;

     System.out.printf("You entered: " + "%.1f %.1f %.1f %.1f %.1f ", weightOne, weightTwo, weightThree, weightFour, weightFive);

     double average = sum / 5;

     System.out.println();

     System.out.println();

     System.out.println("Total weight: " + sum);

     System.out.println("Average weight: " + average);

     double max = MyArr[0];

     for (int counter = 1; counter < MyArr.length; counter++){

        if (MyArr[counter] > max){

           max = MyArr[counter];

        }

     }

     System.out.println("Max weight: " + max);

  }

Morgarella [4.7K]3 years ago
5 0

Answer:

The source code file to this question has been attached to this response. Please download it and go through it. The file contains comments explaining significant sections of the code. Please go through the comments in the code.

Download java
You might be interested in
A counter-flow double pipe heat exchanger is heat heat water from 20 degrees Celsius to 80 degrees Celsius at the rate of 1.2 kg
lakkis [162]

Answer:

L=107.6m

Explanation:

Cold water in: m_{c}=1.2kg/s, C_{c}=4.18kJ/kg\°C, T_{c,in}=20\°C, T_{c,out}=80\°C

Hot water in: m_{h}=2kg/s, C_{h}=4.18kJ/kg\°C, T_{h,in}=160\°C, T_{h,out}=?\°C

D=1.5cm=0.015m, U=649W/m^{2}K, LMTD=?\°C, A_{s}=?m^{2},L=?m

Step 1: Determine the rate of heat transfer in the heat exchanger

Q=m_{c}C_{c}(T_{c,out}-T_{c,in})

Q=1.2*4.18*(80-20)

Q=1.2*4.18*(80-20)

Q=300.96kW

Step 2: Determine outlet temperature of hot water

Q=m_{h}C_{h}(T_{h,in}-T_{h,out})

300.96=2*4.18*(160-T_{h,out})

T_{h,out}=124\°C

Step 3: Determine the Logarithmic Mean Temperature Difference (LMTD)

dT_{1}=T_{h,in}-T_{c,out}

dT_{1}=160-80

dT_{1}=80\°C

dT_{2}=T_{h,out}-T_{c,in}

dT_{2}=124-20

dT_{2}=104\°C

LMTD = \frac{dT_{2}-dT_{1}}{ln(\frac{dT_{2}}{dT_{1}})}

LMTD = \frac{104-80}{ln(\frac{104}{80})}

LMTD = \frac{24}{ln(1.3)}

LMTD = 91.48\°C

Step 4: Determine required surface area of heat exchanger

Q=UA_{s}LMTD

300.96*10^{3}=649*A_{s}*91.48

A_{s}=5.07m^{2}

Step 5: Determine length of heat exchanger

A_{s}=piDL

5.07=pi*0.015*L

L=107.57m

7 0
3 years ago
1. An air standard cycle is executed within a closed piston-cylinder system and consists of three processes as follows:1-2 = con
QveST [7]

Answer:

Explanation: Here it is: 67 Hope that helps! :)

5 0
3 years ago
For a column that is pinned at both ends, the critical buckling load can be calculated as, Pcr = π2 E I /L^2 where E is Young's
gulaghasi [49]

When a slender member is subjected to an axial compressive load, it may fail by a ... Consider a column of length, L, cross-sectional Moment of Inertia, I, having Young's Modulus, E. Both ends are pinned, meaning they can freely rotate ... p2EI L2 ... scr, is the Euler Buckling Load divided by the columns cross-sectional area

6 0
3 years ago
(40 points) Program the following sorting algorithms: InsertionSort, MergeSort, and QuickSort. There are 9 test les uploaded for
babunello [35]

Answer:

Explanation:

MERGE SORT

#include<stdlib.h>

#include<stdio.h>

#include<string.h>

void merge(int arr[], int l, int m, int r)

{

int i, j, k;

int n1 = m - l + 1;

int n2 = r - m;

 

int L[n1], R[n2];

for (i = 0; i < n1; i++)

L[i] = arr[l + i];

for (j = 0; j < n2; j++)

R[j] = arr[m + 1+ j];

i = 0;

j = 0;

k = l;

while (i < n1 && j < n2)

{

if (L[i] <= R[j])

{

arr[k] = L[i];

i++;

}

else

{

arr[k] = R[j];

j++;

}

k++;

}

while (i < n1)

{

arr[k] = L[i];

i++;

k++;

}

while (j < n2)

{

arr[k] = R[j];

j++;

k++;

}

}

void mergeSort(int arr[], int l, int r)

{

if (l < r)

{

int m = l+(r-l)/2;

mergeSort(arr, l, m);

mergeSort(arr, m+1, r);

merge(arr, l, m, r);

}

}

void printArray(int A[], int size)

{

int i;

for (i=0; i < size; i++)

printf("%d ", A[i]);

printf("\n");

}

int main()

{

int arr[1000] = {0};

int arr_size =0;

int data;

char file1[20];

strcpy(file1,"data.txt");

FILE *fp;

fp = fopen(file1,"r+");

if (fp == NULL) // if file not opened return error

{

perror("Unable to open file");

return -1;

}

else

{

fscanf (fp, "%d", &data);    

arr[arr_size]=data;

arr_size++;

while (!feof (fp))

{  

fscanf (fp, "%d", &data);  

arr[arr_size]=data;

arr_size++;    

}

}

printf("Given array is \n");

printArray(arr, arr_size);

mergeSort(arr, 0, arr_size - 1);

printf("\nSorted array Using MERGE SORT is \n");

printArray(arr, arr_size);

return 0;

}

3 0
3 years ago
In almost all cases, touching power lines or coming into contact with energized sources will result in what?
Fynjy0 [20]

Answer:

electrocution

Explanation:

You will end up getting shoked because the electricity is attracted to the water in your body.

6 0
3 years ago
Other questions:
  • If you were to plot the voltage versus the current for a given circuit, what would you expect the slope of the line to be? If no
    14·1 answer
  • The temperature of an electric welding arc is about?
    13·1 answer
  • What does it mean when it says technology is A dynamic process
    7·1 answer
  • A compound machine contains three simple machines with IMAs of 2, 4 and 5, respectively. What is the overall ideal mechanical ad
    15·1 answer
  • How are speed and acceleration related
    6·2 answers
  • Convert 25 mm into in.
    13·1 answer
  • A piston–cylinder device contains 0.78 kg of nitrogen gas at 140 kPa and 37°C. The gas is now compressed slowly in a polytropic
    11·1 answer
  • AC motor characteristics require the applied voltage to be proportionally adjusted by an AC drive whenever the frequency is chan
    10·2 answers
  • Cup-sveg-aph<br><br>I m finding gf<br><br>if anyone interested pls come​
    11·2 answers
  • g A thin-walled pressure vessel 6-cm thick originally contained a small semicircular flaw (radius 0.50-cm) located at the inner
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!