Assume a file containing a series of integers is named numbers.txt and exists on the computer’s disk. Write a program that calculates the average of all the numbers stored in the file.

Answers

Answer 1

Answer:

Explanation:

The following code is written in Java. It assumes that the numbers.txt file is in the same folder as the Java file and the numbers are separated one on each line. It reads the file, adds all the numbers to an array, then adds the numbers into a single variable and finally divides by the total amount of numbers in order to get the average.

public static void main(String[] args) {

       ArrayList<Integer> numbers = new ArrayList();

       try {

           File myObj = new File("numbers.txt");

           Scanner myReader = new Scanner(myObj);

           while (myReader.hasNextLine()) {

               String data = myReader.nextLine();

               numbers.add(Integer.parseInt(data));

           }

           myReader.close();

       } catch (FileNotFoundException e) {

           System.out.println("An error occurred.");

           e.printStackTrace();

       }

       int average = 0;

       for (int x:numbers) {

           average += x;

       }

       average = average / numbers.size();

       System.out.println(average);

   }


Related Questions

**Question of the Day: How can we change the style of text on a
web page?**

Answers

Answer:

The answer to this question is given below in the explanation section.

Explanation:

If you are a user and serving some website pages for exploring the information, then you want to change the text style on a specific page, you are not allowed to do and you can not do it and change the style of a text written on a webpage.

because text style is written by the programmer of those web pages and the programmer can change the style of text in the HTML coding.  

If you are a programmer then you can change the style of a text. Its color, font style, and font size easily in the HTML coding of that page.    

You can also use CSS (cascaded style sheet) with html to change the style of text on a web page while changing text attributes such as font color, font family, text size, and text alignmnet etc.

What is the best prediction she could make about this
semester's text?
Natalia's class read Shakespeare's Romeo and Juliet
last semester and took a field trip to see it performed
live in a community theater. Today, Natalia learned that
her class will read another work by Shakespeare this
semester
It is a play.
It is an adventure.
It is a fairy tale.
It is a fable.

Answers

Answer:its a play

Explanation:

Answer:

A. It is a play

Explanation:

Got the answer correct on the quiz

Write a program that creates an integer array with 40 elements in it. Use a for loop to assign values to each element of the array so that each element has a value that is triple its index. For example, the element with index 0 should have a value of 0, the element with index 1 should have a value of 3, the element with index 2 should have a value of 6, and so on.

Answers

Answer:

public class Main

{

public static void main(String[] args) {

 int[] numbers = new int[40];

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

     numbers[i] = i * 3;

 }

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

     System.out.println(numbers[i]);

 }

}

}

Explanation:

*The code is in Java.

Initialize an integer array with size 40

Create a for loop that iterates 40 times. Inside the loop, set the number at index i as i*3

i = 0, numbers[0] = 0 * 3 = 0

i = 1, numbers[1] = 1 * 3 = 3

i = 2, numbers[2] = 2 * 3 = 6

.

.

i = 39, numbers[39] = 39 * 3 = 117

Create another for loop that iterates 40 times and prints the values in the numbers array

IN PYTHON LANGUAGE

(1) Prompt the user to enter two words and a number, storing each into separate variables. Then, output those three values on a single line separated by a space. (Submit for 1 point)

Enter favorite color:
yellow
Enter pet's name:
Daisy
Enter a number:
6
You entered: yellow Daisy 6

(2) Output two passwords using a combination of the user input. Format the passwords as shown below. (Submit for 2 points, so 3 points total).

Enter favorite color:
yellow
Enter pet's name:
Daisy
Enter a number:
6
You entered: yellow Daisy 6

First password: yellow_Daisy
Second password: 6yellow6

(3) Output the length of each password (the number of characters in the strings). (Submit for 2 points, so 5 points total).

Enter favorite color:
yellow
Enter pet's name:
Daisy
Enter a number:
6
You entered: yellow Daisy 6

First password: yellow_Daisy
Second password: 6yellow6

Number of characters in yellow_Daisy: 12
Number of characters in 6yellow6: 8

Answers

Answer:

favorite_color = input('Enter favorite color:\n')

pet_name = input("Enter pet's name:\n")

number = input('Enter a number:\n')

print('You entered:',favorite_color+' '+pet_name+' '+number)

password1 = favorite_color+'_'+pet_name

password2 = number+favorite_color+number

print('\nFirst password:'+' '+password1)

print('Second password:'+' '+password2)

print('\nNumber of characters in '+password1+': '+str(len(password1)))

print('Number of characters in '+password2+': '+str(len(password2)))

Explanation:

Notice on the pet name I used quotes instead of parenthesis because so I can use the comma on pet's.

This solution worked for me.

Which software programs should students avoid using to create and submit course work? (Choose all that apply). Word, Pages, Numbers, Keynote

Answers

Answer:

tyafana

Explan

ation:n umbers

Suppose the RAM for a certain computer has 256M words, where each word is 16 bits long.What is the capacity of the memory expressed in bytes

Answers

Answer:

The RAM capacity expressed in bytes is

512 million bytes

Explanation:

a) Data and Calculations:

RAM contains 256m words

Each word = 16 bits

1 bit = 0.125 byte

This means that each word will have 2 (16 * 0.125) bytes

Therefore, the RAM contains 256m * 2 = 512 million bytes

b) A bit is 0.125 bytes and a byte is eight times bigger than a bit.  This implies that there are eight megabits in every megabyte, and one gigabyte is eight times bigger than one gigabit.  The 512 million bytes above are about 488.3 gigabytes, since 1 gigabyte equals 1,024 megabytes or 1,046,576 kilobytes.

Katla is a project manager. One of the programmers on her team comes to her and says that he permanently deleted some code mistakenly. After working for weeks with their support technicians to retrieve the code, Katla wants to implement a better system. Which system does she need to start using?

A. WhiteBoard

B. debugging

C. software development life cycle

D. version control

Answers

Answer:

Version Control - Maintains the code log history and changes overtime.

16. A
is an object you can insert in your document, type text in, but can then format in the
same ways you would other objects?
(5 Points)
formatting box
text holder
text box
typing box

Answers

Answer:

The answer to this question is given below in the explanation section.

Explanation:

The correct answer to this question is the Text box.

You can insert a text box as an object in your document, type text in it and you can format it in the same way you would do for other objects.

You can insert the text box using the Insert tab then under Shapes that you can find under the Illustrations group. You can then find Text Box under basic shapes.

While the other options are not correct because:

Formatting box allows you to format the object, text holder and typing box does not mean in this context because text holder is something that can hold the text such as shapes or text box, etc. but these terms are not used in word or in a document.

Write code that will read the contents of umich_buildings.json and load its value into the gobal variable umich_buildings. Note that umich_buildings will be a list.

Answers

Answer:

import json

umich_buildings = []

with open("umich_buildings.json", "r") as json_file:

   content = json.load(json_file)

json_file.close()

for value in content:

   umich_buildings.append(value)

print("the resultant is : ", umich_buildings)

Explanation:

The python source code gets information from a json file, it imports the json package and opens and assigns the json file "umich_building" to the variable "json_file" and continuously parse the json to python with the load() method, then append the items to the global list variable "umich_buildings"

who plays a role in the finanical activites of a company

Answers

Financial managers are responsible for the financial health of an organization. They produce financial reports, direct investment activities, and develop strategies and plans for the long-term financial goals of their organization.

For this project, you will be developing a PY file that contains your code in PyCharm and evaluating a few of the features of PyCharm. If you haven’t already, be sure to install the PyCharm IDE and Python on your computer. Review the tutorials in the Module Two resources to help you install and get started with PyCharm.

In PyCharm, write a program using python that prompts the user for their name and age. Your program should then tell the user the year they were born. Here is a sample execution of the program with the user input in bold:

What is your name? Amanda
How old are you? 15

Hello Amanda! You were born in 2005.

Answers

import datetime

name = input("What is your name? ")

age = int(input("How old are you? "))

year = datetime.datetime.today().year

print("Hello {}! You were born in {}.".format(name, year - age))

I hope this helps!

Which software programs should students avoid using to create and submit course work? (Choose all that apply.

Answers

Answer:

The answer to this question is given below in the explanation section.

Explanation:

You can submit your course work most often in a Word document. Because in the word document, you can insert text, numbers, images, charts, shapes whatever you want such as required for writing a course assignment or course work- easily.  Because your final work should be in a complete document.

The correct options to this question, that you should need to avoid using to create and submit course work are pages, numbers, and keynote.

Because while submitting the course work, you need to submit a complete word document, it is not required to you that you have to submit numbers, pages, or keynotes along with the course assignment. You can create a course assignment or project document in word and submit to your respective teacher. However, you can not create your course work using keynotes or pages, etc as given in the question.

The software programs that students should avoid using to create and submit coursework include pages, numbers, and keynotes.

It should be noted that it's vital that while submitting a course work, one needs to submit a complete word document.

It is not required that the person submits pages, numbers, and keynotes. The most important thing is the word document that'll be submitted. Therefore, the software programs that students should avoid using to create and submit course work include pages, numbers, and keynotes.

Read related link on:

https://brainly.com/question/19788811

what used to produce protein under the direction of DNA?​

Answers


Genes

A gene is the section of DNA required to produce one protein.

Write a method to convert from Celsius to Fahrenheit using the following method header:// convers form Celsius to Fahrenheitpublic static double celsiusToFahrenheit (double celsius)The formula for the conversion is: Fahrenheit = ( 9/5) * Celsius +32

Answers

Answer:

public class Main

{

public static void main(String[] args) {

 System.out.println(celsiusToFahrenheit(10));

}

public static double celsiusToFahrenheit (double celsius){

    double fahrenheit = (9/5.0) * celsius + 32;

    return fahrenheit;

}

}

Explanation:

Create a method named celsiusToFahrenheit that takes one parameter, celsius

Inside the method:

Convert the celcius to fahrenheit using the given formula. Note that, in the formula 9/5 is integer division. You need to convert it to the double so that the result should not be 0. One solution is converting one of the int to decimal, 9/5 → 9/5.0

Return the fahrenheit

Inside the main method:

Call the celsiusToFahrenheit() with some value and print the result

Ask the user how many numbers for which they want to calculate the sum. Using a for loop, prompt the user to enter that many numbers, one-by-one, keeping track of the sum. At the end, after the user entered all numbers, output the sum.

Answers

n = int(input("How many numbers do you want to sum? "))

total = 0

for x in range(n):

   total += int(input("Enter a number: "))

print("Sum: "+str(total))

I hope this helps!

Following are the program to the given question:

Program Explanation:

Defining a variable "Sum" that holds an integer value.In the next step, a variable "t" is defined that uses the input method to input a value from the user-end.After the input value, a for loop is declared that takes the range of the t variable.Inside the loop, another variable "n" is defined that inputs value from user-end and use the "Sum" variable to add its value.Outside the loop, a print method has been used that prints the sum variable in the string with the message.  

Program:

Sum = 0#defining a variable sum that hold an integer value

t= int(input("Enter the total number you want to add: "))#defining a t variable that input value from user-end

for i in range(t):#defining a loop that add inputs values from above user-input range

   n= int(input("Enter value "+str(i+1)+": "))#defining loop that inputs n value

   Sum += n; #defining sum variable that adds user-input value

print("Sum of entered number: "+str(Sum))#using print method that print added value

Output:

Please find the attached file.

Learn more:

brainly.com/question/16025032

Write an application that displays the sizes of the files lyric1.txt and lyric2.txt in bytes as well as the ratio of their sizes to each other.

Answers

Answer:

#include<iostream>

#include<fstream>

using namespace std;

int main() {

  ifstream file_one("lyric1.txt", ios::binary);

  ifstream file_two("lyric2.txt", ios::binary);

  file_one.seekg(0, ios::end);  // retrieving file size of lyric1.txt file

  file_two.seekg(0, ios::end);  // retrieving file size of lyric2.txt file

  // converting the binary file size to an integer.

  int fileOne = file_one.tellg();

  int fileTwo = file_two.tellg();

  cout<<"Size of the lyric1.txt is"<<" "<< fileOne<<" "<<"bytes";

  cout<<"Size of the lyric2.txt is"<<" "<< fileTwo<<" "<<"bytes";

  cout<< fileOne <<" : "<< fileTwo;

Explanation:

The source code gets the file size of two word files and displays them in bytes and also displays the ratio of both files.

What happens when you apply a theme to a form?

Answers

Answer:

it will be customizable, you can design it in a different style

Explanation:

1. What do you think of the use of Moore’s Law to hypothesize a timeframe for the origin of life?
2. How does Moore’s Law apply to the efficiency of algorithms as we discussed in the last class?
3. Where do you think computers will be in 10 years? 100?

Answers

Answer:

1. I think it was actually a very good idea. As time goes on technology is improved, new laws and theories are proven, scientists are disproven, and efficiency of doing certain tasks evolves. Another reason would be, why not? It does not hurt to make a hypothesis or try a new approach.  

1. We spend countless time exploring and digging only to possible never find what we need to exactly pin the first life forms on Earth and when they lived, why not try a new different angle. So, I think that it was a very clever and interesting to use and Moore's Law to hypothesis the origin of life.  

2. Moore's law applies to the efficiency of algorithms because he came up with a way to hypothesis were in technology we should stand after a certain amount of time and how much improvements should be integrated into our computers.

2. Moore’s Law applies to the efficiency of algorithms because Moore created a exponential equation and graph of a hypothesis proven to help guide engineers on a steady path of improvement should be made to  computer processors and components with in a certain amount of time.

3. In a 10 years I think computers would have only made simply yet very effective and efficient improvements. Like longer battery life, or faster speeds, but virus firewalls and defenders. But when faced with 100 years I think that would have lead to a huge drastic change to what the normal idea of a computer is. It would be so high tech to us but with the world our grandkids are living in it'll be normal to have holographic computers.

3. I think that in 10 years computers would have improved much like they have recently, smaller, more compact, faster, and longer lasting, but within 100 years we would have a another invention entirely. Computers would have changed so much more than we could have every thought.

Explanation: I put a few different answers for each question so you can mix and match and use what's easiest for you but both are correct.

Advantages against its counterpart because of its portability​

Answers

Answer:

It is advantageous against its counterpart, which is HTML 5,because of its portability. ... It is the basic pattern of HTML tags. <HTML> It indicates that the file is composed of HTML commands.

It is the language used to create websites because of its portability, this is beneficial against HTML 5, The abstraction behind goods, buttons, and connections is a command, and the further discussion can be defined as follows:

The software used to construct a webpage as well as its contents is the HTML tag this is used to set an instruction to also be invoked by the user.It states that the HTML commands are in the file for its portability, it is beneficial itself against counterpart HTML 5.This is the HTML Tags pattern. It suggests that the HTML instructions are included in the file.

Learn more:

brainly.com/question/4932805

The Mac’s GUI set it apart from earlier operating systems.
True or False

Answers

Answer:

Its true

Explanation:

Just took the test.

What term refers to a sequence of statements in a language that both humans and computers can understand?

a
hexadecimal
b
program
c
binary
d
macro

Answers

Answer your answer is Macro

Explanation:

Macro shares language both the computer and the programmer can undestand.

Write a application that can determine if a 5 digit number you input is a palindrome. If the number is a palindrome then print "The number is a palindrome." If it is not then print "The number is NOT a palindrome"

Answers

Answer:

Written in Python:

num = int(input("Number: "))

strnum = str(num)

if len(strnum) !=5:

    print("Length must be 5")

else:

    if(strnum[::-1] == strnum):

         print("The number is a palindrome.")

    else:

         print("The number is NOT palindrome.")

Explanation:

This prompts user for input

num = int(input("Number: "))

This converts user input to string

strnum = str(num)

This checks the length of the string

if len(strnum) !=5:

    print("Length must be 5") If length is not 5, this prompt is printed

else:If otherwise

    if(strnum[::-1] == strnum): The compares the string reversed with the original

         print("The number is a palindrome.") If both are the same, this line is executed

    else:

         print("The number is NOT palindrome.") If otherwise, this line is executed

Which software programs should students avoid using to create and submit course work? (Choose all that apply.

Answers

Answer:

you need to add the list

Explanation:

Write a Python program string_functions.py that defines several functions. Each function re-implements Python's built-in string methods

Answers

Answer:

def length( mystring):

   count = 0

   for i in mystring:

       count += 1

   return count

def reversed( mystring):

   strlist = []

   for i in range(length(mystring)):

       strlist.append(mystring[(length(mystring) - 1) - i])

       txt = "".join(strlist)

   return txt

string = 'Yolanda'

print(reversed(string))

Explanation:

The python module defines two functions 'reversed' and 'length'. The length function counts the number of characters in a string variable while the reversed function reverses the string variable value.

in pycharm, write a program that prompts the user for their name and age. your program should then tell the user the year they were born. here is a sample execution of the program what is your name? Amanda how old are you? 15. This is what I have so far but I can't get pycharm to tell me the year I was born.
import datetime

name = input("What is your name? ")

age = input("How old are you? ")

year = datetime.datetime.now().year

print("Hello ' + name + ' you were born in " (year - age))

Answers

Let's address the few mistakes in your code so far. First, age is of type string and year is of type int. You're trying to subtract an int by a string and that doesn't work. Also, you have inconsistent quotes "Hello '. You should always use the same type of quote. The (year - age)) isn't properly formatted into the print statement. There is no plus adding it.

Here's my working code:

import datetime

name = input("What is your name? ")

age = int(input("How old are you? "))

year = datetime.datetime.now().year

print("Hello " + name + " you were born in " + str((year - age)))

I just fixed your code. Best of luck.

In python, date and time seem to be not its type of data, but the date and time named module can be imported for it to work with the time and date. So, the program and its description can be defined as follows:

Program Explanation:

Importing "datetime" package.Defining two-variable "name, age" in which we input value from user-end.Defining another variable "year" that holds current year value.In the next step, the print method has used that prints the user name with the born year.

Program:

import datetime#import package datetime

name = input("What is your name? ")#defining a variable name that uses an inputs method to input string value

age = int(input("How old are you? "))#defining a variable age that uses an inputs method with the int to input value

year = datetime.datetime.now().year#defining a variable year that takes current value in it

print("Hello " + name + " you were born in " + str((year - age)))#defining a print method that print name value with born year

Output:

Please find the attached file.

Learn more:

brainly.com/question/19032453  

Is this statement true or false?

A plain text e-mail and the same text entered into a word processing document would be about the same file sizes.


true

false

Answers

False, the word file will be a little bit larger

Answer:

false

Explanation:

explain mechanical computer

Answers

Answer:

A mechanical computer is built from mechanical components such as levers and gears, rather than electronic components. The most common examples are adding machines and mechanical counters, which use the turning of gears to increment output displays.

Explanation:

hope this answer was helpful

In series connection, if we have two symmetric devices connected with 10 V battery, voltage for each device will be.. .5V or 10V
Pleaseee help I am crying

Answers

Answer:

5V

Explanation:

In series, you divide the voltage over the devices, so 10V / 2 devices = 5V.

In parallel, each device would get the full battery voltage.

See picture.

Write a program that inputs numbers and keeps a running sum. When the sum is greater than 100, output the sum as well as the count of how many numbers were entered.

Answers

total = 0

count = 0

while total < 100:

   num = int(input("Enter a number: "))

   total += num

   count += 1

print("Sum: {}".format(total))

print("Numbers Entered: {}".format(count))

I'm pretty sure this is what you're looking for. Best of luck!

Which line of code in this program is MOST likely to result in an error

Answers

Answer:

What are the choices?

Explanation:

Answer:

line 2 it needs quotation marks :D

Explanation:

Other Questions
Terell lives in Washington, D.C., where he can see the Potomac River from his bedroom window. When he sees this river, Terell thinks of swimming, boating, fun, and friends. What type of mental image is this?A. analogicalB. symbolic C. both analogical and symbolic D. representative Please help me!! Write one digit on each side of 36 to make a four-digit multiple of 36. How many different solutions does this problem have? slope of (-3, 1), (1, 9) and slope of (-2, -9), (-1, -7) Assuming that the half-life of Isotope Q is 7.5 minutes, what amount of an original150.0 gram sample of Isotope Q will remain after a half hour?1. 37.5 g2. 18.75 g 3. 80 g 4. 9.375 g The figure below shows the letter Z and four of its transformed images-A, B, C, and D: A coordinate plane is shown. The letter Z has endpoints at negative 6 comma 3, negative 6 comma 1, negative 4 comma 1 and negative 4 comma 3 and has a diagonal line that goes from top right to bottom left in between. A is a shape that has endpoints at 4 comma 3, 4 comma 1, 6 comma 3 and 6 comma 1 and has a diagonal line that goes from top left to bottom right. B has endpoints at negative 6 comma negative 1, negative 6 comma negative 3, negative 4 comma negative 1 and negative 4 comma negative 3 and has a diagonal line that goes from top right to bottom left. C has endpoints at negative 3 comma negative 1, negative 3 comma negative 3, negative 1 comma negative 1, negative 1 comma negative 3, and has endpoints that go from top left to bottom right. D has endpoints at 2 comma negative 1, 2 comma negative 3, 4 comma negative 1, and 4 comma negative 3 and has a diagonal that goes from top right to bottom left. Which of the four images was formed by a reflection of the letter Z? (5 points) A B C D what are the 3 main states of matter in water?/ What is 1+1 tell me eeeeee pleaseeeeeeeeeeeee helpppppppppppppppppppp During the years between 1940 and 1950 what generalization can you make from this graph? Colin gets xxwages each week. After he pays his tax of tt, he then pays his rent of 250. He shares what's left between himself and his wife. How much do they each get? What facilitated the rise of a global economy? A. the decline of communist regimes around the world B. an era of relative peace, with significantly less warfare in the world C. greater competition among countries D. the advent of information technology, which made communication easier Find a point-slope equation of the line having the given slope and containing the given point. m=6; (6,4) What is the slope of a line that passes through the points (0, 1) and (2, 6)?please answer fast as can What is -3x + 15 = equal to Please help me out! answer all four questions please Im tired and want to go to bed. Sry I dont get this math-_- but plz help which statement is true of the particles that make up a substance? a. particles in a liquid have more energy than particles in a gas. b. particles in a liquid and particles in a solid have the same amount of energy. c. particles in a gas have more energy than particles in liquid. d. particles in a solid have moe energy than particles in a gas. find the mean, variance, and standard deviation of the binomial distribution with the given values of n and p. n= 60, p= 0.3 In five to eight sentences, describe the achievements of the Tang Dynasty.Please write original answers and only answer if you know it shshshshdhd Pls need help. Due in a few minutes