I am looking for help in the code at areas with //, please help.
I am also getting a compiler error with (import java.Datemaybe this will be cured when other lines are ??
Code:import java.util.Scanner; import java.util.Random; import java.io.*; import java.Date; public class PGM1 { public static void main(String[] args) throws IOException {String fname; Random rrd = new Random(System.currentTimeMillis()); Scanner kbd = new Scanner(System.in); System.out.println("What is the output filename? "); fname = kbd.nextLine(); PrintWriter outfile = new PrintWriter(fname); System.out.println("What's the size of the array? "); int sz = kbd.nextInt(); if(sz < 25 || sz > 100) System.out.println("The array size is out of range." + "Please enter a size between 25-100. "); int [] nums = new int[sz]; System.out.println("Random Numbers: "); System.out.println(); // Fill nums[] with random numbers in the range 0 thru 23456 // Write (to outFile) numbers from nums, 5 to a line - well aligned int highest = nums[0]; for (int index = 1; index < nums.length; index++) { if (nums[index] > highest) highest = nums[index]; } int lowest = nums[0]; for (int indexL = 1; indexL < nums.length; indexL++) { if (nums[indexL] < lowest) lowest = nums[indexL]; } int total = 0; int average; for (int indexA = 0; indexA < nums.length; indexA++) total +=nums[indexA]; average = total/nums.length; System.out.print("Smallest: " + "/t" + lowest); System.out.println("/t/t/tLargest: " + "/t" + highest); System.out.println("Average: " + "/t" + average); // close outFile


LinkBack URL
About LinkBacks
maybe this will be cured when other lines are ?? 



Reply With Quote





Bookmarks
Algorithms and Data Structures
Java tutorials
Algorithms Forum