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
How can an Excel table be added to a Word document? Check all that apply.
densk [106]

Answer:

A and B

Explanation:

3 0
3 years ago
Write a C program that displays your name and address (or if you value your privacy, a frictionless name and address)
rosijanka [135]

Answer:

Following are the program in c language

#include <stdio.h> // header file

int main() // main method

{

   char name[90]="mantasa"; // storing name

   char add[90]="120 lal bangla mumbai"; // storing address

    printf("\n Name:%s\nAddress:%s",name,add); // print name and address

   return 0;

}

Output:

Name:mantasa

Address:120 lal bangla mumba

Explanation:

In this program we are declaring the two array of char type which will store the name and address . after that we display name and address.

7 0
3 years ago
HELP FAST PLEASE
never [62]

Answer:

I am not sure can you explain a little more

7 0
2 years ago
Read 2 more answers
What is a segmentation?
lana66690 [7]

Answer:

Segmentation means to divide the marketplace into parts, or segments, which are definable, accessible, actionable, and profitable

3 0
2 years ago
Nathan would like to save his PowerPoint presentation as a video that can be replayed easily on any device at full quality. Whic
aniked [119]

Answer:

Presentation Quality

Explanation:

7 0
3 years ago
Other questions:
  • Discuss Hashing and how it is utilized within the IT industry. Also, discuss how Hashing can improve our sorting and searching r
    12·1 answer
  • What will be the topic of the essay?
    14·1 answer
  • Instructions Write a program that allows the user to enter the last names of five candidates in a local election and the number
    8·1 answer
  • 1 what elements of composition are under your control in photoshop
    13·1 answer
  • How is technology closely linked to creativity
    15·1 answer
  • If you're using the paintbrush tool and want to change the color of the paint being used what should you change
    6·1 answer
  • What is the function of the command prompt?
    8·1 answer
  • Write, in your own words, a one-two paragraph summary on the Running Queries and Reports tutorials. Apply critical thinking and
    10·1 answer
  • Which of the following is NOT a type of insurance fraud?
    14·2 answers
  • Kitchen Gadgets
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!