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
What do you understand by the term polysome?​
jasenka [17]

Answer:

A polyribosome (or polysome or ergasome) is a group of ribosomes bound to an mRNA molecule like “beads” on a “thread”. It consists of a complex of an mRNA molecule and two or more ribosomes that act to translate mRNA instructions into polypeptides.

6 0
3 years ago
Q2: Mark True or False in the corresponding Answer sheet (0.5 point each)
Zinaida [17]

The answers to the question are:

  1. True
  2. True
  3. True
  4. True
  5. False
  6. true
  7. True
  8. True
  9. False
  10. False
  11. false
  12. False
  13. True
<h3>Which words are combined to form malware?</h3>

Malware is known to be a kind of malicious software and it covers  viruses, worms, trojans and other bad computer programs that is often used by hackers to wreak and steal information from system.

The types Of Expansion Cards are:

  • Sound Card
  • Graphics Card
  • Network Interface Card
  • Modem,

A sound card known as an audio card which is said to be an internal expansion card that helps to give input and output of audio message to and from a computer system.

Learn more about  sound card from

brainly.com/question/26964065

#SPJ1

3 0
2 years ago
What can I do If my Texas Instrument TI-84 calculator is not giving accurate answers?
zlopas [31]

Answer:

replace the batteries possibly

Explanation:

4 0
2 years ago
When you identify the data elements in a new database, you typically subdivide data elements into?
DochEvi [55]
When you identify the data elements in a new database, you typically subdivide data elements into <span>the smallest practical component. 

Thank you for posting your question here at brainly. I hope the answer will help you. Feel free to ask more questions.
</span>
4 0
3 years ago
A newly opened law firm in Kirkland decides to create a small website that provides a brief introduction of the firm, its missio
Ivan

Answer:

Flat web architecture

Explanation: A flat web architecture is a type of web Structure where to link chain exists, in this type of web architecture,users can access the web site with few number of clicks such as in one, two or three clicks with a maximum of four clicks.

One of the basic importance when dealing with web pages is the number of clicks before the page requested can be reached. The lower the number of clicks the better.

5 0
3 years ago
Other questions:
  • Suppose that a computer virus infects your computer and corrupts the files you were going to submit for your current homework as
    12·1 answer
  • If a function needs to return more than one value, as a rule of good programming style, you should change it to a(n) ___________
    6·1 answer
  • On laptops with a smart card reader installed, where is the smart card reader usually located?
    13·1 answer
  • Pls answer i need to turn it in today!!
    15·1 answer
  • The welcome screen of the program 123D consists of ___
    15·1 answer
  • Why is it important to isolate evidence-containing devices from the internet?
    11·1 answer
  • In Outlook 2016, the Tell Me function can be accessed by
    15·2 answers
  • Use the drop-down menus to explain what happens when a manager assigns a task in Outlook.
    6·2 answers
  • What skills did Carl work on, and what steps did he take to reach his long term goals?<br>​
    10·1 answer
  • Tim is a project manager. He is brainstorming with his team about problems that could arise during the next phase of the project
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!