Given the code below, public static void main(String[] args) throws FileNotFoundException File inputFile = new File(Data.txt);...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Given the code below, public static void main(String[] args) throws FileNotFoundException File inputFile = new File("Data.txt"); Scanner in= new Scanner(inputFile); int sum = 0; int count = 0; while (hasNextInt()) { sum+= in.nextInt(); count++; in.close(); System.out.println(sum / count); Considering Data.txt contains-3 1234 What would be the output? Given the code below, public static void main(String[] args) throws FileNotFoundException File inputFile = new File("Data.txt"); Scanner in= new Scanner(inputFile); int sum = 0; int count = 0; while (hasNextInt()) { sum+= in.nextInt(); count++; in.close(); System.out.println(sum / count); Considering Data.txt contains-3 1234 What would be the output?
Expert Answer:
Answer rating: 100% (QA)
The code youve provided reads integers from a text file Datatxt and calculates the average of these ... View the full answer
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
A firm has just paid a dividend of $1.5 per share (Do = $1.5) and its common stock now sells for $25 per share. The firm's dividend growth rate is 10% every year. The firm plans to issue the new...
-
How do you simplify the max method in the following, using the conditional operator? 1: /** Return the max of two numbers */ 2: public static int max ( int num1, int num2 ) { 3: int result; 4: 5: if...
-
Modify, compile, and test the client program in Table 25.17 and the server program in Table 25.16 to allow the client to provide the pathname of a short file stored on the server host. The server...
-
A machine fills containers with a particular product. The standard deviation of filling weights computed from past data is 0.6 ounces. If only 2% of the containers hold less than 18 ounces, what is...
-
Locate the 2011 financial statements for The Walt Disney Company on the Internet. 1. Did Disney have any below-the-line items in 2011? Explain. 2. Disney's net income increased from $3,963 million in...
-
As end A of the slender bar is pulled to the right with the velocity v, the bar slides on the surface of the fixed half- cylinder. Determine the angular velocity @ of the bar in terms of x.
-
What circumstances might influence the growth or shrinkage of the nonprofit sector?
-
Silver Company manufactures kites and has the following information available for the month of April: Required: Using the weighted-average method, complete each of the following steps: 1. Reconcile...
-
how to forming an argument on topic. like business communication and productivity
-
One subunit of Racer Sports Company had the following financial results last month: Requirements 1. Complete the performance evaluation report for this subunit (round to two decimal places). 2. Based...
-
Home Landscaping Value Expenditures ($1,000) ($1,000) A landscaping company has collected data on home values (in thousands of $) and expenditures (in thousands of $) on landscaping with the hope of...
-
Nichols Cycles manufactures chainless bicycles. On March 31, Nichols Cycles had 150 bikes in inventory. The company has a policy that the ending inventory in any month must be 10% of the following...
-
Altira Corporation provides the following information related to its inventory during the month of August 2024: August 1 Inventory on hand-3,100 units; cost $7.20 each. August 8 Purchased 15,500...
-
Could you pleasedraw/design this product concept? You may use any CADsoftware, such as Pro-E, AutoCAD, Solidworks,etc. All I need is a detail drawing of the product concept withproper dimensions....
-
Calculate the theoretical acceleration when the mass is constant, and the net force is changed. Record the calculations in the data table on the Student Response Sheet. The acceleration is the ratio...
-
Explain the respective roles of insurance contracts and derivatives in risk management. How are these two approaches to risk management different and why is there a need for both? Use examples to...
-
2. Suppose George, a custom herbicide applicator is running a business where there is lot of competition. At a rate of $7 per acre, he is competitive and can sell his service for as many acres as he...
-
Use the T account for Cash below to record the portion of each of the following transactions, if any that affect cash. How do these transactions affect the companys liquidity? Jan. 2 Provided...
-
Design a class named Time. The class contains:??The data fields?hour,?minute, and?second?that represent a time.? A no-arg constructor that creates a Time object for the current time. (The values of...
-
Write the following method that displays the bit representation for the last byte in an integer:public static?String getBits(int?value)For a hint, see Programming Exercise 5.44. Write a program that...
-
Given a set of cities, the central city is the city that has the shortest total distance to all other cities. Write a program that prompts the user to enter the number of the cities and the locations...
-
Celestial Inc. is organized into 3 distinct divisions. The company is currently contemplating the elimination of either Division 1 or Division 2 because they are showing a pre-tax loss. An annual...
-
Wayflaire Inc. produces home products. The cost to manufacture a case ( 36 sets) of its most popular set of casual dinnerware is as follows: The average sales price for a case of dinnerware is \(\$...
-
Jill Catanac, purchased a new laptop computer just before this school term for \(\$ 300\). Shortly after the semester began, her new computer was damaged when it was accidentally dropped. Returning...
Study smarter with the SolutionInn App