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
Which of the following is an example of a reliable source?
avanturin [10]

Answer:

A

Explanation:

A pamphlet on the economics of bridge building published by the organization citizens against government spending.

5 0
3 years ago
Ohm's law states that the current (I) in amps equals the voltage (E) in volts decided by the resistance (R) in ohm's. If you con
Hitman42 [59]

Answer:

1.14 * 10^-3  amperes

Explanation:

According to ohms law

V = IR   ---- ( 1 )

V = voltage  = 2.4 * 10^3 v

I = current  = ?

R = resistance =  2.1 * 10^6 Ω

from equation 1

I = V / R

 = ( 2.4 * 10^3 ) / (2.1 * 10^6 )

 = 1.14 * 10^-3  amperes

7 0
3 years ago
There is a proposal in Brooklyn to construct a new mid-rise apartment building on a vacant lot at the intersection of Avenue A a
Soloha48 [4]

Answer:

a. Park should be adjacent to 48th Street, b. Difference in noise level = 707dBa, c. Yes

Explanation:

Data given for Avenue A

Cars = 496, Medium Truck = 52, Heavy Truck = 19, Buses = 10

Data given for 48th Street

Cars = 822, Medium Truck = 22, Heavy Truck = 8, Buses = 3

Consider the PCEs to be Cars = 1, Medium Truck = 13, Heavy Truck = 47, Buses = 18

a. Noise Level = Number of vehicles x PCE

For Avenue A

Noise level = (496 x 1) + (52 x 13) + (19 x 47) + (10 x 18) = 2245dBa

For 48th Street

Noise level = (822 x 1) + (22 x 13  + (8 x 47) + (3 x 18) = 1538dBa

The park should adjacent to 48th street as it is quieter than Avenue A

b. Let the Setback be 50ft. We know that the reduction of noise for 100ft = 5-8 dBa, hence

For Avenue A Noise Reduction due to 50 ft = (8/100) x 50 = 4dBa

Noise at Setback distance = 2245 - 4 = 2241dBa

Considering the same setback the noise at 48th street would be = 1538 - 4 = 1534 dBa

The difference is noise level between the two sides would be = 2241 - 1534 = 707 dBa

c. Yes the developer concerns are valid because there is a clear difference in noise levels of the two sites. This can be seen even after setting the same Setback. Locating the park next to Avenue A will cause serious noise problems.

8 0
4 years ago
Air is to be heated steadily by an 8-kW electric resistance heater as it flows through an insulated duct. If the air enters at 5
Furkat [3]

To solve this problem it is necessary to apply the concepts related to the heat exchange of a body.

By definition heat exchange in terms of mass flow can be expressed as

W = \dot{m}c_p \Delta T

Where

C_p = Specific heat

\dot{m}= Mass flow rate

\Delta T = Change in Temperature

Our values are given as

C_p = 1.005kJ/kgK \rightarrow Specific heat of air

T_1 = 50\°C

\dot{m} = 2kg/s

W = 8kW

From our equation we have that

W = \dot{m}c_p \Delta T

W = \dot{m}c_p (T_2-T_1)

Rearrange to find T_2

T_2 = \frac{W}{\dot{m}c_p}+T_1

Replacing

T_2 = \frac{8}{2*1.005}+(50+273)

T_2 = 326.98K \approx 53.98\°C

Therefore the exit temperature of air is 53.98°C

6 0
3 years ago
Suppose you are implementing a relational employee database, where the database is a list of tuples formed by the names, the pho
m_a_m_a [10]

Answer:

Explanation:

val db = ("John", "x3456", 50.1) :: ("Jane", "x1234", 107.3) ::

        ("Joan", "unlisted", 12.7) :: Nil

 

type listOfTuples = List[(String, String, Double)]

def find_salary(name: String) = {

 def search(t: listOfTuples): Double = t match {

   case (name_, _, salary) :: t if name == name_ => salary

   case _ :: t => search(t)

   case Nil    =>

     throw new Exception("Invalid Argument in find_salary")

 }

 search(db)

}

def select(pred: (String, String, Double) => Boolean) = {

 def search(found: listOfTuples): listOfTuples = found match {

   case (p1, p2, p3) :: t if pred(p1, p2, p3)  => (p1, p2, p3) :: search(t)

   case (p1, p2, p3) :: t if !pred(p1, p2, p3) => search(t)

   case Nil => Nil

   case _ => throw new Exception("Invalid Argument in select function")

 }

 search(db)

}

 

println("Searching the salary of 'Joan' at db: " + find_salary("Joan"))

println("")

 

val predicate = (_:String, _:String, salary:Double) => (salary < 100.0)

println("All employees that match with predicate 'salary < 100.0': ")

println("\t" + select(predicate) + "\n")

7 0
3 years ago
Other questions:
  • Air enters the compressor of an ideal cold air-standard Brayton cycle at 100 kPa, 300 K, with a mass flow rate of 6 kg/s. The co
    11·1 answer
  • Use the orange points (square symbol) to plot the initial short-run industry supply curve when there are 20 firms in the market.
    5·1 answer
  • Some engineers have developed a device that provides lighting to rural areas with no access to grid electricity. The device is i
    13·1 answer
  • suppose we number the bytes in a w-bit word from 0 (less significant) to w/8-1 (most significant). write code for the followign
    11·1 answer
  • Q: Draw shear and bending moment diagram for the beam shown in
    5·1 answer
  • For what two reasons do countries specialize? Countries specialize so that opportunity costs can be increased. Countries special
    13·1 answer
  • A thick spherical pressure vessel of inner radius 150 mm is subjected to maximum an internal pressure of 80 MPa. Calculate its w
    9·1 answer
  • n open feedwater heater operates at steady state with liquid water entering inlet 1 at 10 bar, 50°C. A separate stream of steam
    8·1 answer
  • 3. A steel pipe of outside diameter 20 mm and thickness 3 mm is
    14·1 answer
  • The static weight distribution is changed laterally by
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!