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]
2 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]2 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
I need help with these
solmaris [256]

Answer:

Choose internet is the right answer

7 0
2 years ago
1 punto
masya89 [10]

Answer:

Retailing.

Explanation:

La venta al por menor o retailing es el suministro de bienes físicos a los consumidores para uso personal, sea en pequeña o grandes cantidades, siempre que esté destinado a consumidores finales. Es un sector que consta de diferentes ramas (como la industria alimentaria, la industria de la moda, la industria del mobiliario para el hogar, etc.). El comercio minorista es el último eslabón de la cadena de suministro que va desde el fabricante hasta el consumidor.

4 0
3 years ago
A bot can use a _______to capture keystrokes on the infected machine to retrieve sensitive information.
fgiga [73]

Answer:

keylogger.

Explanation:

A keylogger can be defined as a software program or hardware device designed for monitoring and recording the keystrokes entered by an end user through the keyboard of a computer system or mobile device.

Basically, a keylogger can be installed as a software application or plugged into the USB port of a computer system, so as to illegally keep a record of all the inputs or keys pressed on a keyboard by an end user.

In order to prevent cyber hackers from gaining access to your keystrokes, you should install an anti-malware software application such as Avira, McAfee, Avast, Bitdefender, Kaspersky, etc.

An antivirus utility is a software application or program that's used to scan, detect, remove and prevent computer viruses such as Malware, Trojan horses, keyloggers, botnets, adwares etc.

In conclusion, a bot can use a keylogger to capture keystrokes on the infected machine to retrieve sensitive information.

3 0
3 years ago
Best web hosting for beginners in 2020?
Evgen [1.6K]

Answer:

Digital Ocean (but you need to set it up first)

Explanation:

If you are a student, I would recommend Digital Ocean, as you get £50 free credit as part of the GitHub Student Pack. (I believe you have to pay in a little bit however). There are also other reputable hosting providers, AWS should do the trick. For people just starting out, I would recommend hosting from their own machine. If you don't want to pay ever, and are just using basic HTML/CSS, you can use GitHub Pages as a means to host websites.

DO / AWS will only provide you with a blank Linux box, it would then be up to you to install suitable website hosting software - such as Apache/Nginx ect...

8 0
3 years ago
Create a new folder in python and make it read only
igor_vitrenko [27]
Making the file read-only will not allow the file to be rewritten again. For this, we need to modify the permissions of the file. To achieve this, we will make use of the os module in Python more specifically, the chmod() of the os module.

The coding part is extremely simple and will contain very few lines as we are not doing much but changing the permissions. Using the chmod(), we can change the mode of the path, setting it to any mode using the suitable flags from the stat module. Both these modules come inbuilt with Python and hence you need not install anything additionally.

The entire code to change the file to read-only is as follows;

import os
from stat import S_IREAD
# Replace the first parameter with your file name
os.chmod("sample.txt", S_IREAD)
.

You can verify if the code was executed correctly by checking the file’s permissions. To do that :

Right-click on the file and click properties.
Under the attributes section, you will find the read-only checkbox checked.
I hope you found this article useful and it helped you make a file read-only. You can do more than just making the file read-only by using the appropriate flag from the stat module.
8 0
2 years ago
Other questions:
  • Greg is writing a report on becoming an advertising and promotions manager. Complete the report by correctly filling in the miss
    12·1 answer
  • A blank is the full web Address for particular website<br> (Computer technology)
    14·1 answer
  • Please answer this I know that no one else does but I can't think right now
    10·1 answer
  • What else can Xbox do to help reduce negative online behavior? (250 minimum)
    6·1 answer
  • Eli needs to export files from his mailbox into a single file that is portable and can be backed up to removable media. Which fi
    7·1 answer
  • Synapse is not working and is crashing every time you attach it. What should you do?
    13·1 answer
  • Select the true statement about the motherboard.
    9·1 answer
  • Amogus :0) owo have a good day y'all
    12·1 answer
  • . A binary search has a right subtree but no left subtree. What noes contains that least element in the tree
    11·1 answer
  • Compare and discuss between electromechanical and electronic era of computer​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!