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]
3 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]3 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
If a friend changes the password on your phone how do you get into it if you dont know the password
kotegsom [21]
Ask your friend to tell you the password
3 0
3 years ago
Select the properties of the sn1 reaction mechanism.
musickatia [10]

It is - not stereospecific , a reaction in which the stereochemistry of the reactants controls the outcome of the reaction; - bimolecular at rate-determining step , it involves two molecules; - first order, - rates is governed by the stability of the carbocation that is formed.

7 0
3 years ago
3) According to the five-component model of information systems, the ________ component functions as instructions for the people
Ludmilka [50]

Answer:HUMAN RESOURCES AND PROCEDURE COMPONENTS

Explanation: Information systems are known to contain five components, these components help to describe the various aspects and importance of Information systems.

They Include The DATABASE AND DATA WAREHOUSE components(act as the store for all data), The COMPUTER HARDWARE(the physical components of the information systems such as computer harddrive etc)

THE COMPUTER SOFTWARE( the software which includes all the non physical and intangible assets of the information system),

THE HUMAN RESOURCES AND PROCEDURES COMPONENT( which gives instructions to the users).

THE TELECOMMUNICATIONS.

7 0
3 years ago
O A self-confident person knows that:
arlik [135]
C you should believe in yourself and your abilities
3 0
3 years ago
Which of these purchases is most likely to be paid for with a credit card
Vesna [10]

Answer:

plane ticket?

Explanation:

7 0
3 years ago
Other questions:
  • What is a digital certificate? Select one: a. It is a means of establishing the validity of an offer from a person, entity, web
    7·1 answer
  • You are given two processors P1 and P2 that execute the same instruction set but have different architectures. The instructions
    9·1 answer
  • Self contained sequences of actions to be performed are?
    6·1 answer
  • Frank develops a questionnaire for his study on Internet dating. One of his questions asks, "How do you feel about Internet dati
    14·2 answers
  • Write an expression to print each price in stock_prices. Sample output with inputs: 34.62 76.30 85.05
    9·1 answer
  • Which statement describes Augmented Reality (AR) technology?
    12·1 answer
  • Assignment 6: Animation
    7·1 answer
  • Alguien porfavor me dice como cambiar de idioma en brainly
    15·1 answer
  • We love silky. she is very honest join this by using conjunction ​
    11·2 answers
  • An online bank wants you to create a program that shows prospective
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!