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
lianna [129]
2 years ago
7

g Create your own data file consisting of integer, double or String values. Create your own unique Java application to read all

data from the file echoing the data to standard output. After all data has been read, display how many data were read. For example, if 10 integers were read, the application should display all 10 integers and at the end of the output, print "10 data values were read" Demonstrate your code compiles and runs without issue. Respond to other student postings by enhancing their code to write the summary output to a file instead of standard output.
Computers and Technology
1 answer:
Jlenok [28]2 years ago
5 0

Answer:

See explaination

Explanation:

//ReadFile.java

import java.io.File;

import java.io.FileNotFoundException;

import java.util.Scanner;

public class ReadFile

{

public static void main(String[] args)

{

int elementsCount=0;

//Create a File class object

File file=null;

Scanner fileScanner=null;

String fileName="sample.txt";

try

{

//Create an instance of File class

file=new File(fileName);

//create a scanner class object

fileScanner=new Scanner(file);

//read file elements until end of file

while (fileScanner.hasNext())

{

double value=fileScanner.nextInt();

elementsCount++;

}

//print smallest value

System.out.println(elementsCount+" data values are read");

}

//Catch the exception if file not found

catch (FileNotFoundException e)

{

System.out.println("File Not Found");

}

}

}

Sample output:

sample.txt

10

20

30

40

50

output:

5 data values are read

You might be interested in
What will the following code print out: int numbers [] = {99, 87, . 66, 55, 101}; for (int i = 1; i < 4; i++) cout << n
forsale [732]

Answer:

87 66 55

Explanation:

Array is used o store the multiple values with same data type.

the array show a decimal value .66, i assume this is enter by mistake because option has no decimal value.

The index of the array is start from zero, it means the first element store in the array at position zero.

In the for loop the variable 'i' start from 1 not zero and it goes to i<4 means i=3.

So, it access the element from 2 to 4 because the index is position of element less than 1.

Therefore, 87 66 55 print.

5 0
3 years ago
What will be a fundamental aspect of future games??
alina1380 [7]
I believe that the answer to the question provided above is that with the age of improving technology, the aspects of future games will be based more unto electronic games or e-games.
Hope my answer would be a great help for you.    If you have more questions feel free to ask here at Brainly.
7 0
3 years ago
Read 2 more answers
write a pseudo code and flow chart that take a number as input and prints multiplication table up to 10
Troyanec [42]

PSEUDOCODE:

1. DECLARE number: INTEGER

2. DECLARE multiple: INTEGER

3. INPUT number  

4. FOR counter FROM 1 TO 10 DO

5.     multiple <-- number * counter

6.     PRINT number, " * ", counter, " = ", multiple

7. ENDFOR


<em>1. declaring a variable "number" as an Integer</em>

<em>2. declaring a variable "multiple" as an Integer</em>

<em>3. The user inputs the value of number</em>

<em>4. FOR loop where variable "counter" increments by 1 after every iteration</em>

<em>5. sets the value for variable "multiple" as the value of number * counter</em>

<em>6. prints out for example "3 * 1 = 3" and will continue till counter reaches 10</em>

<em>7. Ends the for loop</em>

FLOWCHART below

hope it helped

8 0
3 years ago
________ are devices in a computer that are in either the on or off state
Vanyuwa [196]
The appropriate response is Electrical Switches. These are electromechanical gadgets that are utilized as a part of electrical circuits to control, recognize when frameworks are outside their working reaches, flag controllers of the whereabouts of machine individuals and work pieces, give a way to manual control of machine and process capacities, control lighting, et cetera.
6 0
3 years ago
Who is responsible for keeping your facility in compliance? A) Technicians B) Supervisors C) Owners D) All of the above
zhenek [66]

Based on my personal experience in the workforce, all of the above would be the correct answer. That's based off my experience though. Owners would regularly come in and talk to our managers and employees to make sure everything was kept in order and in compliance. The only other answer I could see fit would be supervisors. Hope I was able to help :)

3 0
2 years ago
Other questions:
  • Hot five was the famous band of which musician?
    14·1 answer
  • Functions that are built-in into PHP to perform some standard operations.
    15·1 answer
  • Clicking on the Spelling &amp; Grammar button is one way to correct a spelling error in Word. Please select the best answer from
    7·2 answers
  • Explain why the intangibility of Software System poses special problems for Software Project Management
    11·1 answer
  • A 5-stage MIPS pipeline has a register file without forwarding mechanism. How many NOPs (or bubbles) will you need to add to mak
    9·1 answer
  • As a prospective student, what is the best reason to request an interview with your college application?
    6·1 answer
  • What does an "embedded video" mean
    7·1 answer
  • SeleCT all correct text​
    5·1 answer
  • If a person communicates indirectly and attaches little value to
    6·1 answer
  • What does a companys code of ethics cover
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!