Write Java code that creates an array of n integers myArray, by taking n integers from the user with duplications, and do the following:
1- Print the elements of myArray,
2- Calculate the sum and the mean of myArray elements,
3- Copy the values of myArray to an array list named myArrayList, the array list must contain the elements of myArray without duplication,
4- Calculate the sum and the mean of myArrayList elem

Answers

Answer 1

Answer:

this should be what you need

Explanation:

import java.util.*;

public class ABC{

 public static void main(String[] args) {

   int n;

   //create scanner object

   Scanner sc = new Scanner(System.in);

   //ask for size of array

   System.out.print("Enter the size of array (n): ");

   //read the input

   n = sc.nextInt();

   //create an array of n length

   int [] myArray = new int[n];

   //ask user for array elements

   System.out.printf("Enter %d integers: ", n);

   //read array elements

   for(int i =0 ;i <5; i++)

     myArray[i] = sc.nextInt();

   

   //print the elements if myArray

   System.out.print("1 - The values of myArray are: [");

   for(int i =0 ; i < n; i++){

     System.out.print(myArray[i]);

     if(i < n-1)

       System.out.print(", ");

   }

   System.out.print("]\n");

   //calculate mean and sum of myArray elements

   int sum = 0;

   double mean = 0;

   for(int i = 0; i < n; i++)

     sum += myArray[i];

   

   mean = (sum*1.0)/n;

   //print the sum and mean of myArray

   System.out.printf("2 - The sum is: %d. The mean is: %.1f\n", sum, mean);

     

   //create an arraylist

   ArrayList<Integer> myArrayList = new ArrayList<Integer>();

   //copy the value of myArray to an arraylist without duplicates

   for(int i = 0; i < n; i++){

     if(!myArrayList.contains(myArray[i]))

       myArrayList.add(myArray[i]);

   }

   sum = 0; mean = 0;

   //display the values of myArrayList

   System.out.print("3 - The values of myArrayList are: [");

   for(int i =0 ; i < myArrayList.size(); i++){

     System.out.print(myArrayList.get(i));

     if(i < myArrayList.size()-1)

       System.out.print(", ");

   }

   System.out.print("]\n");

   //calculate sum and mean of myArrayList elements

   for(int i = 0; i < myArrayList.size(); i++)

     sum += myArrayList.get(i);

   mean = (sum*1.0)/myArrayList.size();

   //print the sum and mean of myArrayList

   System.out.printf("4 - The sum is: %d. The mean is: %.2f\n", sum, mean);

 }

}


Related Questions

Functions of file in computer ​

Answers

[tex]\huge{\textbf{\textsf{{\color{pink}{An}}{\red{sw}}{\orange{er}} {\color{yellow}{:}}}}}[/tex]

File in computers are used to store data, information and commands.

Thanks hope it helps.Pls mark as brainliest.

Rachel selected a part of her audio file in the audio editing software and increased its decibel value. Which audio editing effect has Rachel used here?
A.
fade out
B.
normalize
C.
noise Reduction
D.
amplify
E.
compressor

Answers

lmk when someone has an answer

Answer: D. Amplify

Explanation:

Correct Plato answer

No links it’s just a normal question about iPhones.
If you have someone in your contacts you talk with a lot but like everyday you delete the conversation multiple times will you stop receiving texts from that person even if you text them and it says delivered?

Answers

Answer:

You will still get the messages. You are just deleting the messages from YOUR device not the other persons, in order to stop recieving messages from the person you block them. In order to stop receving notifications, you put them on DND. But, if you talk to them everyday I would assume you would not want to stop receiving messages from them.

What does the revolver do?

sends the domain name and requests the IP address

sends the IP address and requests the content of the web page

sends the IP address and requests the domain name

sends the domain name and requests the content of the web page

Answers

Answer:

last one

Explanation:

Engineers at Edison Laboratories developed a _____ strip that allowed them to capture sequences of images on film.


kinetoscope

selenium

cotton

celluloid

Answers

The answer: Kinetoscope

Answer:

Celluloid

Explanation:

It is Sis

PLEASE HELP ME!!! Please don't answer if you're just going to guess.

In this line from a data file, what do you call the comma?
dog, 23, 15
The comma is _____
-Choices-
a BOL set of characters,
an EOL set of characters,
a delimiter.

Answers

Answer:

a

Explanation:

Answer:

BOL

Explanation:

Fatima has 3 packs of batteries. Each pack contains 4 batteries. She gives her brother 8 batteries to put in his toy robot. Let b represent the number of batteries Fatima has left. Which equation could be used to find the value of b?

Answers

Answer: See explanation

Explanation:

Let b represent the number of batteries Fatima has left.

The equation that can be used to find the value of b goes thus:

(3 × 4) = b + 8

12 = b + 8

b = 12 - 8

Therefore, based on the above equation, the number of batteries that Fatima has left will be 4.

an option already selected by windows is called____ ( default option/ default selection)​.
this is urgent

Answers

Answer:

default option

Explanation:

What is the output? Choose 3 options.

>>>import time
>>>time.localtime()

an indicator of whether or not it is a leap year

the day of the year

the month

the number of seconds after the epoch

the time zone's name

Answers

Answer:

the number of seconds after the epoch

the day of the year

the month

Explanation:

The time() function returns the number of seconds passed since epoch. For Unix system, January 1, 1970, 00:00:00 at UTC is epoch (the point where time begins).The function time. asctime(), present if the time module can be used to return the current date and time.

The output from the information given will be:

the number of seconds after the epochthe day of the yearthe month

It should be noted that input and output are simply the communication between a computer program and its user.

The output refers to the program that's given to the user. In this case, based on the information, the output from the information given will be the number of seconds after the epoch, the day of the year, and the month.

Read related link on:

https://brainly.com/question/23968178

Which of the following belongs in a website citation? (select all that apply)

the place where the author works

the Internet address or web page address

the person or organization responsible for the website

page numbers

the date when you got the information

Answers

The place where the author works I think

Answer:

the Internet address or web page address

the person or organization responsible for the website

the date when you got the information

Explanation:

Ishmael would like to capture a selected potion of his screen and then capture action he performs on that selected portion. What should he do?


Use a video from my PC command

User the insert screen recording control

Create a poster frame

Use an embed code

Answers

Answer: User the insert screen recording control

Explanation:

Since Ishmael wants to capture a selected potion of his screen l, after which he'll then capture the action that he performs on that selected portion, he should use the insert screen recording control.

It should be noted that on most keyboards, there's an "insert screen" button. Also, Ishmael can simply open the window that he wants to screenshot and then click the screenshot button.

Therefore, the correct option is B.

Choose the expression that belongs in the blank in order to have the output shown.

>>> a = 5
>>> print(_____)
The value is5

"The value is " + str(a)

"The value is" , str(a)

"The value is " , str(a)

"The value is" + str(a)

Answers

Answer:

Option B

Explanation:

Given

a = 5

and if the value allotted to variable a is to be printed, the following command will be used

print "The values is", str(a)

Hence, option B is correct

Which connection type is a wireless method of sending information using radio waves?
O Cable
O Wi-Fi Fiber
Otic cable
O Broadband
please i need help but dont put up a wed site​

Answers

Hoped that helped lol, but yeah, the rest of them need wires

Edit: CAN I HAVE BRAINLIEST.

What is the correct HTML for adding a background color?


Question 7 options:


< background>yellow


< body background-color=yellow>


< body bg="yellow">


< body style="background-color:yellow;">

Answers

Answer:

< body background-color=yellow>

Explanation:

This is the correct HTML command that is used for adding a background color of choice.

Consider the classes below: Which of the following statements is true? Group of answer choices The value of counter will be different at the end of each for loop for each class. The value of j will be the same for each loop for all iterations. Both The value of counter will be different at the end of each for loop for each class and The value of j will be the same for each loop for all iterations are true. Neither The value of counter will be different at the end of each for loop for each class nor The value of j will be the same for each loop for all iterations is true.

Answers

Answer:

probly

Explanation:

Both The value of counter will be different at the end of each for loop for each class and The value of j will be the same for each loop for all iterations are true.

Suggest three ways in which celebrating an occasion influences food choices?

Answers


Celebrating influences food in more than 1 way

Answer:

It can completely show the different flavors that might have influenced the people at the past like their traditional spices and their main ingredients. It also is just a big part of celebrations because usually every single celebration comes with food and drinks.

True or False

Operating systems control the loading of software applications onto a computer

All OSs offer user preferences allowing you to customize your computer

Answers

I used this from a other.

False

Software is the collection of large program or instruction of codes, which is used to perform some task. It is of two types of system software and application software.

The system software is used as a container for the application software and it is used to handle all other software it is used to operate the system.

Application software is used to perform any operation. This type of software can be used by the user if it is installed on the local machine on any system software

The operating system is also the part of the system software because it is used to operate the system and it is also the soul of the computer system which is also the function of the system software but the above question states that the operating system is not the part of the system software which is not correct. Hence false is the correct answer to the above question.

Which of the following is the term for a device (usually external to a computer) that is plugged into a computer's communication
port or connected wirelessly?
An attachment
A peripheral
A flash drive
A plug-in

Answers

A device, usually external to a computer that is plugged into a computer's communication port or is connected wirelessly. Common peripherals are keyboards, mice, monitors, speakers, and printers

The term for a device (usually external to a computer) that is plugged into a computer's communication  port or connected wirelessly is:

B. A peripheral

According to the given question, we are asked to find the correct term for a device which is plugged to a computer's communication port wirelessly

As a result of this, we can see that a peripheral device is used to connect to a computer wirelessly and some common examples include a keyboard, mouse, joystick, etc.

Therefore, the correct answer is option B

Read more here:

https://brainly.com/question/20488785

HELPPP ME PLEASEEE!!

Answers

It’s the last one! The key to an effective persuasion is to know what you want and be clear about your response.

what is the most popular monitor​

Answers

Probably a television or a radio I guess

20 Points and Brainliest!!!!!!
Select the correct answer.
Amara is designing a website to encourage people in a city to vote in local elections. She wants to include a web page that shows first-time voters the steps to follow to register and vote in the elections. How can Amara best use multimedia to show the voting process on the web page?

A.
by providing a paragraph of instructions with pictures
B.
by providing an audio file along with downloadable pictures
C.
by creating a brief animation with optional text instructions
D.
by creating a static slideshow of the steps showing just pictures
E.
by adding automatically playing audio with text instructions

Answers

Answer:

I think E, sorry if I'm wrong.

Answer:

I think it might be C

Explanation:

PLEASE HELPPPPP ASAP, 50 POINT'S + BRAINLIEST

1.) Online crimes causing loss of money: give 5 names and examples to each

2.) Online misconduct or crimes targeting medical offices and services: give 5 names and examples to each

3.) Online misconduct or crimes that you have experienced: give 5 names and examples to each

Answers

Answer:

1. Cybercrimes are online crimes that cause loss of money some examples are: Identity fraud, Cyber bribery, Debit/credit card fr/ud, and Email fr/ud.  

2. In medical offices devices linked to CT scans are able to be h/cked, there is r/nsomw/re that uses their devices. Since medic/l computers are always linked to the internet. it makes it easier for them to be h/cked. They make an employee click on an e-mail carrying m/lw/re, then the cybercrimin/ls encrypt p/tient data then dem/nd p/yment for its decryption.

3. This is a personal question but if you have ever been sc/mmed or witnessed someone being sc/mmed or almost got  sc/mmed it might apply to this question

How does a computer get the server's IP and how does it know which way to the server?

Answers

The browser connects to the domain name server (DNS) and retrieves the corresponding IP address for that specific server. It knows which way to go due to it being programmed to follow the exact instructions given by human interaction, its own hardware, and the software installed onto it.

what is the best wi-fi name you have ever seen?

Answers

Answer:

bill wi the science fi

Explanation:

one day when rahul went to his computer lab and saw that all the computers were connected to a single printer and whoever is giving a command to print, the print out comes from that printer. can you name the concept of communication? class 8 computer one word answer..​

Answers

Explanation:

you can connect multiple PCs to the wireless printer and print your documents from each one of them as long as the printer can be connected to the same network . You need the disc that came with the wireless printer to install the correct drivers on your computers and laptops.

hope it helps ( brainleist please )

so i just went to play forge of empires and when i logged on to it all of my progress was gone and i was so far in to it

Answers

Answer:

That's tough...

Explanation:

Answer:

ok and?

Explanation:

This is not a question

You manage the website for your company. The website uses a cluster of two servers with a single shared storage device. The shared storage device uses a RAID 1 configuration. Each server has a single connection to the shared storage and a single connection to your ISP. You want to provide redundancy so that a failure in a single component does not cause the website to become unavailable. What should you add to your configuration to accomplish this

Answers

Answer: Connect one server through a different ISP to the Internet

Explanation:

With RAID 1 configuration, data can be simultaneously copied from one particular disk to another, thereby creating a replica.

Since the person wants to provide redundancy so that a failure in a single component does not cause the website to become unavailable, one server should be connected through a different ISP to the Internet.

PLEASE HELP! Please dont answer if your going to guess
You have three modes for opening a file. You wish to create a new file and write data to

the file. What letter belongs in this line of code?

myFile = open("another.txt", "_____")
r
w
a
d

Answers

Answer:

r

Explanation:

I literally learned this today when trying to make a python server with an html file:)

Answer:

w

Explanation:

4. Which of the following is a face-to-face meeting between the hiring party and the applicant?
A. Interview
B. Application
C. Résumé
D. Reference

Answers

Answer:

A. interview

Explanation:

You are planning a storage solution for a new Windows server. The server will be used for file and print services and as a database server. The new server has five hard disks, all with equal capacity. Your storage solution should meet the following requirements: System files should be on a volume separate from data files. All volumes should be protected so that the server can continue to run in the event of a failure of one of the disks. The data volume should be optimized for improved disk access times. You will use Windows Disk Management to create and manage the volumes. What should you do

Answers

Answer:

Explanation:

The best solution for this scenario would be to first create a mirrored volume for the system volume using two of the available disks and then a single RAID 5 volume with the remaining 3 disks for the data volume. This setup will allow all of the data to be backed up so that if one of the disks fails the server will continue running accordingly. The RAID 5 volume offers error checking and redundancy for the data, therefore, allowing the data to be accessed quickly and efficiently with far greater security and far less chance of data becoming corrupt.

Other Questions
Which term refers to a word that is derived from a verb and ends in -ing but functions as a noun in a sentence?infinitiveparticiplegerundverb Horace Mann stated, Be ashamed to die, until you have won some victory for humanity. What do you think he meant by this statement to his students If someone helps me ill give them brainlest Please help,Find the perimeter of the figure to the nearest hundredth please I need help ASAP Which word correctly completes the sentence?Mi hermana va atemprano, va a dlcharse, va a vestirse y arreglarse.o lastimarseenfermarseO levantarseO probarse Please help 50 points to whoever answers, and brainliest to best answer!!!! 1. Es el opuesto del enfermo:2. Es la tienda donde se venden medicinas:3. Para recibir antibiticos, es necesario tener una de un mdico.4. Si una mujer va a tener un beb, ella est5. La persona que est enferma y va al consultorio del mdico es el/la6. Sin los no es posible ver.7. Es el tipo de mdico que le ayuda con problemas de los dientes:8. Es la persona (puede ser hombre o mujer) que ayuda a la mdica:9. Cada ao, hay muchas personas, especialmente los viejos, que mueren de estaenfermedad aunque es posible recibir una vacuna contra la enfermedad:10. Si tengo un problema con un diente, el dentista puede11. Cuando una personadebe cubrir la boca con algo, por ejemplo el brazo o unpauelo.12. Usualmente, cuando una persona tiene un se siente mal pero no tienefiebre. Estornuda y tose y tiene mocos en la nariz.13. Si tu tienes muy alta, no debes venir a la escuela.14. Por ejemplo, hay muchos tipos como aspirina, Tylenol y Motrin. Hay que tomarloscon agua.15. Me ca en la escalera y me la pierna.16. Mi abuela tuvo una en el estomago y ahora est en el hospital.17. Si tienes un accidente muy grave, debes ir a la sala de18. No puedo respirar; estoy muy19. Antes de participar en los deportes en esta escuela, es necesario tener20.No puedo hablar muy bien. Me duele mucho la21. Me siento muyNecesito sentarme un momento.22. Me duele mucho el estmago; creo que voy a23.Hay mucha en mi dedo. Necesito una curita.24. Fiebre alta y manchas rojas (red blotches) en la cara son los del sarampin(measles). What happened when Hitler attacked Poland?Hitler lost power and was replaced by a new government.The United States declared war on Germany.Great Britain and France declared war on Germany.Great Britain and France appeased Germany by doing nothing. 3/4+ (1/3 1/6)- (-1/2)=___1 3/4 2 1/43/4 3 1/4 Please help! Brainlyest answer!! PLSPLSPLS HELP ME, I'LL GIVE BRAINLIEST AND SPAM YOUR ACC WITH 5 STARS Please, can anyone confirm that my answers are correct?Will give brainiest to first correct answer! (No links pls)PLZ HELP Helppppp meeee llsss Green anoles were forced out of their established habitat of trees, plants, walls and fences by invasive brown anoles. The green anoles then had to find new habitats in wetlands and tree crowns. This example illustrates the concepts of: The circumference of circular hot tub at a hotel is 56.5 yards. What is the diameter of the hot tub? Patricia needs 2 pints of purple icing to decorate cupcakes. She will use the following recipe for 1 pint of purple icing. 1 pint of white icing4 1/4 teaspoons of blue food coloring2 1/2 teaspoons of red food coloring.explain two different ways for patricia to find total number of teaspoons of blue and red food coloring necessary to make 2 pints of purple icing Number 11 choose three of the words to use in a sentence What was the result of the Great Schism of 1054?The Emperor Justinian split the Byzantine Empire into two parts.Muslims split into groups of Sunnis and Shiites.The Seljuk Turks conquered Constantinople.he Eastern Orthodox Church split off from the Roman Catholic Church. Megan surveyed a random sample of 60 students at her school and found that 42 of them ride the bus to school each day. If there are 320 students at Megans school, about how many of them ride the bus to school each day?