Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!