Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.io.*; public class Practice_Assignment_8 { public static void main(String args) throws IOException { int randomNumber; int i; int total = 0; PrintWriter fileOutput =

import java.io.*; public class Practice_Assignment_8 { public static void main(String args) throws IOException { int randomNumber; int i; int total = 0; PrintWriter fileOutput = new PrintWriter("numbers.dat"); Random rand = new Random(); for (i = 1; i <= 20; i ) { randomNumber = rand.nextInt(100); fileOutput.println(randomNumber); } fileOutput.close(); Scanner fileInput = new Scanner(new File("numbers.dat")); System.out.println("The numbers in the file \"numbers.dat\": "); while (fileInput.hasNext()) { randomNumber = fileInput.nextInt(); System.out.printf(randomNumber " "); total = total randomNumber; } System.out.print(" The total of the numbers is: " total); fileInput.close(); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

Approach to population ?

Answered: 1 week ago

Question

The concept of development ?

Answered: 1 week ago

Question

To make available communication media?

Answered: 1 week ago

Question

Explain the treaty of purandar in ancient time ?

Answered: 1 week ago

Question

Merits of Women education ?

Answered: 1 week ago