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
serious [3.7K]
3 years ago
13

Create a new Java class called AverageWeight. Create two arrays: an array to hold 3 different names and an array to hold their w

eights. Use Scanner to prompt for their name and weight and store in correct array. Compute and print the average of the weights entered using printf command. Use a loop to traverse and print the elements of each array or use Arrays class method to print. Submit your code.
Computers and Technology
1 answer:
Ainat [17]3 years ago
5 0
<h2>Answer:</h2><h2></h2>

//import the Scanner class

import java.util.Scanner;

//begin class definition

public class AverageWeight{

       //declare the main method

    public static void main(String []args){

     

       //declare the names array

       String [] names = new String [3];

       

       //declare the weights array

       double [] weights = new double [3];

       

       //Create an object of the Scanner class

       Scanner input = new Scanner(System.in);

       

       

       //create a loop to ask for the names and weights.

       for(int i = 0; i< names.length; i++){

           System.out.println("Enter name " + (i+1));

           names[i] = input.next();

           

           System.out.println("Enter weight " + (i+1));

           weights[i] = input.nextDouble();

           

       }

       

       

       

       //find the sum of the weights

       double sum = 0.0;

       for(int j = 0; j< weights.length; j++){

           sum += weights[j];

           

       }

       

       //find the average

       double average = sum / weights.length;

       

       //print out the average of the weights

       System.out.printf("%s%f \n", "The average of the weights is ", average);

       

       

       //print out the elements of the names array

       System.out.println("Names : ");

       System.out.print("{ ");

       for(int i = 0; i< names.length; i++){

           

           System.out.print(names[i] + " ");

           

       }

       System.out.print(" }");

       

       

       //print out the elements of the weights array

       System.out.println();

       System.out.println();

       System.out.println("Weights : ");

       System.out.print("{ ");

       for(int i = 0; i< weights.length; i++){

           

           System.out.print(weights[i] + " ");

           

       }

       System.out.print(" }");

       

     

    } //end of main method

   

   

} //end of class definition

<h2>Sample Output</h2>

>> Enter name 1

Peter

>> Enter weight 1

12.0

>> Enter name 2

Joe

>> Enter weight 2

23.4

>> Enter name 3

Paul

>> Enter weight 3

23.9

The average of the weights is 19.766667  

Names :  

{ Peter Joe Paul  }

Weights :  

{ 12.0 23.4 23.9  }

<h2>Explanation:</h2>

The code contains comments explaining important lines.

The source code file has been attached to this response.

A sample output has also been provided.

Download java
You might be interested in
The following memo does not follow the correct format. What should be changed? To: Stacy, Allen, and Emma Date: August 12, 2012
miss Akunina [59]
<span>The From: line should appear under the To: line.

</span>
4 0
3 years ago
Read 2 more answers
Explain program and programming with two examples of each<br>Help​
evablogger [386]

Answer:

program (noun) is executable software that runs on a computer. ... Examples of programs include Web browsers, word processors, e-mail clients, video games, and system utilities. These programs are often called applications, which can be used synonymously with "software programs." On Windows, programs typically have an .

7 0
3 years ago
Travis completes his assignments on a word processor. He wants to make sure that his documents are free from spelling or grammat
mrs_skeptik [129]

Answer:

C:F7 I TAKE COMPUTER CLASAES

3 0
4 years ago
Read 2 more answers
The 16 broad career options developed by the US department of education are called
In-s [12.5K]
The answer is career clusters. 
6 0
3 years ago
Which is not a factor that leads to technological advancement?
Taya2010 [7]
The inflation rate is the rate of increase in aggregate prices (things becoming more expensive over time), primarily driven by an increase in the money supply. The effect of inflation on an economy is debatable, and can have positive and negative implications. It generally moves very closely with a growth in the money supply, so that real prices are not heavily affected by inflation in the long-run.
Inflation is not related to technological advancement, but the nominal change in prices. 

New methods, advanced devices, and firms' incentive to become more productive all logically contribute to more advanced technology. 

The answer is A) inflation rate
5 0
3 years ago
Other questions:
  • Which BI tool or technique would be most useful in predicting the likelihood of a fire in a building? a. Data mining b. Dashboar
    9·1 answer
  • The _____ icon looks like a clipboard with a page of paper attached. Cut Copy Paste Clipboard
    5·1 answer
  • ____________ facilitates the processes that help an organization function by applying information and communication technologies
    5·1 answer
  • Which are examples of non-linear presentations? Choose all that apply.
    11·1 answer
  • I will give Brainliest and Extra points for correct answers!!!
    13·2 answers
  • Date
    6·1 answer
  • Write the name of main ore of silver.Write any two application of sliver​
    14·1 answer
  • 19. Fatigue can help improve your reaction time.<br> False<br> O True
    8·2 answers
  • Explain the concepts of GIGO—garbage in, garbage out. Why do you think it’s a helpful concept in coding? How do you think it can
    8·1 answer
  • State four input device that are used for playing gaming programs​
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!