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
We use _____command to get data from the user? (python)
Genrish500 [490]

Answer:

INPUT

Explanation:

EXAMPLE PYTHON CODE

_______________________________________________________

INPUT CODE:

_______________________________________________________

foo = input('foo: ')#Have some text printed before the input field

bar = foo

print(bar)

_______________________________________________________

OUTPUT CODE:

_______________________________________________________

foo: Hello World!

Hello World!

>>> bar

'Hello World!'

>>>foo

'Hello World!'

5 0
3 years ago
Write the definition of a function named newbie that receives no parameters and returns true the first time it is invoked (when
kondaur [170]

Answer:

The function definition to this question can be described as follows:

bool newbie() //defining a bool method newbie

{

static bool y = true ; // defining a static bool variable y and assign value true

bool t1=y; //defining bool variable t1 and assign value of variable y

y=false; // assigning value in variable y

return t1; // return value of variable t1

}

Explanation:

The program to this question can be described as follows:

Program:

#include <iostream> //defining header file

using namespace std;

bool newbie() //defining a bool method newbie

{

static bool y = true ; // defining a static bool variable y and assign value true

bool t1=y; //defining bool variable t1 and assign value of variable y

y=false; // assigning value in variable y

return t1; // return value of variable t1

}

int main() //defining main method

{

int s,s1; //defining integer variable s,and s1

s=newbie(); // variable s that call method

cout<<s<<endl; //print value

s1=newbie();//variable s that call method

cout<<s1;  //print value

return 0;

}

Output:

1

0

Description:

The description of the above function can be described as follows:

  • In the above method definition a boolean method "newbie" is declared, which can't accept any parameters, inside the method, two boolean variable "y and t1" is declared.
  • In this variable, variable y is a static boolean variable, that assigns a true value, and in t1 variable, we hold static variable value.  
  • In the next step, the "y" variable assigns a value, that is false and returns variable t1 value.
  • In the next step, the main method is declared, inside these two integer variable s, s1 is declared, that calls a method, and prints it value in the first time, it will print 1, that means the false and second time it will print 0, that means false.
7 0
3 years ago
The term _____ refers to computers that are among the fastest of any in the world at the time of their introduction. mainframes
Studentka2010 [4]

Answer:

The answer is "Supercomputers".

Explanation:

A supercomputer is a device with or near the highest computer operating price. These computers have typically used in scientific and technical systems with huge libraries or amounts of computing. It applies to machines, that are at the time of their launch are one of the fastest in the world, and the incorrect option can be described as follows:

  • A mainframe computer is used in large organizations.
  • A quantum computer is a computing tool that uses experimentally computational systems directly.
  • The supermini and mini super, both computers are used in researches.
6 0
3 years ago
Which statement is true for a career as a graphic designer?
Brrunno [24]

Answer:

The answer is B.

Explanation:

As a graphic designer you are responsible for almost anything you do! :)

Hope this helps

6 0
3 years ago
7. Application software is a program or group of programs designed for end-users.<br> True<br> False
Genrish500 [490]

Answer:

True

Explanation:

A software refers to "instructions that tell a computer what to do. Software comprises the entire set of programs, procedures, and routines associated with the operation of a computer system" (Encyclopedia Britannica).

There are two types of software;

i) system software

ii) Application software

An application software helps the user to perform specific tasks on the computer. It was specifically designed for the end user.

A typical example of an application software is the Microsoft office which could be used to prepare documents using the computer.

5 0
3 years ago
Other questions:
  • witch of the following is a good way to choose your location as you develop your study method? A. Going where most of your frien
    6·1 answer
  • Assume you have a byte-addressable machine that uses 32-bit word (integers are 32-bit) and you are storing the following informa
    5·1 answer
  • Which are factors that go into a project plan? choose four answers
    14·1 answer
  • The association between a UCS and a CS can be extended to include more stimuli (more stimuli related to the CS can elicit the CR
    7·1 answer
  • Online banking tools allow you to pay bills from your computer. <br> a. True<br> b. False
    5·2 answers
  • When you use information hiding by selecting which properties and methods of a class to make public, you are assured that your d
    14·1 answer
  • Hi! This is python coding. Please don't take advantage, actually, answer!
    11·1 answer
  • Which are aspects of the post-production stage?
    9·1 answer
  • How many types of window in Qbasic​
    11·1 answer
  • To behave ethically means
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!