How to aggregate values stored inside an array in java - java

I am creating a simple games score report generator program which takes input and turns it into a .txt file. It takes a name, a game name, an achievement score and minutes played and I want to be able to tally up the amount of games input, add up the achievement score and also add up the minutes (and convert to hours).
This is an example of how my output to .txt looks at the moment -
This is an example of how I would like an output to look -
How do I aggregate data that was input into the console and stored in an array to get results that I want?
PrintWriter writer = new PrintWriter(new FileOutputStream("Gaming Report Data", true));
writer.println("Player : " + gamerName);
writer.println();
writer.println("--------------------------------");
writer.println();
String[] report = gamerReport.split(":");
writer.println("Game: " + report[0] + ", score= " +report[1] + ", minutes played= " +report[2]);
writer.println();
writer.close();
Source code
package JavaProject;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
import java.nio.file.*;
public class JavaProject {
private static final int minutesPlayed = 0;
private static char[] input;
public static void main(String[] args) {
//variables
int hrs = minutesPlayed * 60;
int mins;
String gamerName, gamerReport = null;
int gameCount;
int errorCount;
//Main data storage arrays
String[] gameNames = new String[100];
int[] highScores = new int[100];
int[] minutesPlayed = new int [100];
#SuppressWarnings("resource")
Scanner Scan = new Scanner(System.in);
//formatting for output and input
System.out.println("////// Game Score Report Generator \\\\\\\\\\\\");
System.out.println(" ");
//User enters either their name or quit. Entering a name will move on to next part
for ( ; ; )
{
System.out.print("Enter your Name.");
System.out.println(" ");
gamerName = Scan.nextLine();
for(int b = 1; b < 99; b++ ) { //this is making the code loop 100 times
//user is given an example of input format
System.out.println(" ");
System.out.println("Input Gamer Information " + "Using Format --> Game : Achievement Score : Minutes Played");
System.out.println("FALSE DATA FORMAT WILL CAUSE ERROR");
System.out.println(" ");
//another data input guide which is just above where data input is in console
System.out.println("Game : Achievement Score : Minutes Played");
gamerReport = Scan.nextLine();
String[] splitUpReport; // an array of string
if (gamerReport.equalsIgnoreCase("quit")) {
System.out.println("You have quit!");
return;
}
splitUpReport = gamerReport.split(":");
int i = 0;
//copy data from split text into main data storage arrays
gameNames[i] = splitUpReport[0];
highScores[i] = Integer.parseInt(splitUpReport[1].trim() );
minutesPlayed[i] = Integer.parseInt(splitUpReport[2].trim());
//output to file using a PrintWriter using a FileOutPutStream with append set to true within the printwriter constructor
//
try
{
PrintWriter writer = new PrintWriter(new FileOutputStream("Gaming Report Data", true));
writer.println("Player : " + gamerName);
writer.println();
writer.println("--------------------------------");
writer.println();
String[] report = gamerReport.split(":");
writer.println("Game: " + report[0] + ", score= " +report[1] + ", minutes played= " +report[2]);
//writer.println("Games Played : " + minutesPlayed);
writer.close();
} catch (IOException e)
{
System.err.println("You have made an error with data input");
}
}
System.out.println("You have quit!");
}
}
public static char[] getInput() {
return input;
}
public static void setInput(char[] input) {
JavaProject.input = input;
}
}

So I am assuming that your array data structure looks like this:
Object[] report = new Object[] {new String(), new Integer(), new Integer()}
where the first entry is the game name, the second is the score, and the third is the time played.
I would suggest that you bundle this data into its own object instead of tracking every 3 positions in an array. Try:
public class Game
{
private String name; public String getName() { return name; }
private int score; public int getScore() { return score; }
private int minutesPlayed; public int getMinutesPlayed() { return minutesPlayed; }
public Game(String name, int score, int minutesPlayed)
{
this.name = name;
this.score = score;
this.minutesPlayed = minutesPlayed
}
#Override
public String toString()
{
return "Game: " + name + ", score= " + score + ", minutes played= " + minutesPlayed);
}
}
You can then use this object to represent game data and hold and array of these objects like this:
Game[] games = new Game[]{
new Game("Game 1", 52, 89),
new Game("Game 2", 57, 58),
new Game("Game 3", 67, 86)
};
This array allows us to access each game as a single entity; for example games[0] would get the reference to the 1st game object in the array. These games can have their data accessed by calling the "getters" for the 3 fields contained in the Game object. games[0].getName() would return the name for the first Game object; likewise, games[0].getMinutesPlayed() would return the minutes played for the first game.
Since we overrode the toString method offered to all classes from java's object class to output a string of the data desired in the way your first file I/O was structured. You can call writer.println(games[i]) where i is and index in your array of games to write the data for a individual game.
To concatenate this data into the output you desired. We can do the following:
// get the number of games played
int gamesPlayed = games.length;
// get the raw data on score and time
int totalScore = 0;
int totalMinutesPlayed = 0;
for(int i = 0; i < games.length; i++)
{
totalScore += games[i].getScore();
totalMinutesPlayed += games[i].getMinutesPlayed;
}
// compile the output string
String output = "Games Played: " + gamesPlayed
+ "\n\nTotal Achievement: " + totalScore
+ "\n\nTotal Time: " + totalMinutesPlayed
+ " (" + totalMinutesPlayed / 60
+ " hours and " + totalMinutesPlayed % 60
+ " minutes).";
// write the string to the file
writer.println(output);

Suggestion:
Create a model of the data as a new simple class:
public class GameReportModel{
String gamename = null;
String username = null;
int score = 0;
int minutesplayed = 0;
}
Now you can use an ArrayList of this model to store data before generate the report:
//Declare
ArrayList<GameReportModel> myArray = new ArrayList<GameReportModel>();
//Populate (example) for each input
GameReportModel myobj = new GameReportModel();
myobj.gamename = "My Game"; //<<from input source
myobj.username = "John"; //<<from input source
myobj.score = 20; //<<from input source
myobj.minutesplayed = 45; //<<from input source
myArray.add(myobj);
// Iterate
for(GameReportModel line : myArray){
writer.println("Player : " + line.username);
... and sumarize for each Player
}
Now you can build some scripts to sort by name, game. This method turn it easy but consume more virtual machine resources (memory and steps). But you can manipulate data with another perspective.
Add and remove Array elements easy.

Related

Sorting Arrays In Java soicanpost

my question is how would I sort the arrayofnames and arrayofdownloads so they're in ascending order and each name matches with it corresponding number of downloads. i've been trying for 4 hours and i can't seem to wrap my head around it
thanks
import java.util.*;
import java.util.stream.*;
public class short6
{
public static void main(String[] args)
{
String[] arrayofnames = new String[4];
int[] arrayofdownloads = new int[4];
printmessage(arrayofnames, arrayofdownloads);
details(arrayofnames, arrayofdownloads);
System.exit(0);
}
public static void printmessage(String[] arrayofnames, int[] arrayofdownloads)
{
Scanner scanner = new Scanner(System.in);
int totalDownloads = 0;
for (int i = 0; i < arrayofnames.length; i++)
{
System.out.println("What is track " + (i + 1));
arrayofnames[i] = scanner.nextLine();
System.out.println("How many thousands of times has it been downloaded? ");
arrayofdownloads[i] = Integer.parseInt(scanner.nextLine());
}
Arrays.sort(arrayofnames);
Arrays.sort(arrayofdownloads);
System.out.println("The track downloaded the most is " + arrayofdownloads[0]+".");
}
public static void details(String[] arrayofnames, int[] arrayofdownloads)
{
int totaldownloads = IntStream.of(arrayofdownloads).sum();
System.out.println("The track downloaded the most is " + arrayofdownloads[0]+".");
System.out.println("The total number of downloads of these 4 tracks was " + totaldownloads * 1000 +".");
System.out.println("\nThe details of the downloads are");
for (int i = 1; i < arrayofnames.length; i++)
{
System.out.println(arrayofnames[i]);
System.out.println((arrayofdownloads[i]));
}
}
}
I'd start creating a Song (e.g.) class that contains both the song name, and the number of downloads:
public class Song {
private String name;
private int downloads;
public Song(String name, int downloads) {
this.name = name;
this.downloads = downloads;
}
public String getName() {
return this.name;
}
public int getDownloads() {
return this.downloads;
}
}
And then, create an array of songs:
Song[] arrayOfSongs = new Song[4];
And load it from the input:
arrayOfSongs[i] = new Song(scanner.nextLine(), Integer.parseInt(scanner.nextLine()));
Now you just need to sort it using a comparator:
Arrays.sort(arrayOfSongs, new Comparator<Song> () {
public int compare(Song o1, Song o2) {
// Sorting by name
return o1.getName().compareTo(o2.getName());
}
});
Or, as #Benoit has said in the comments, it would be even easier this way (Java 8 or up):
Arrays.sort(arrayOfSongs, Comparator.comparing(Song::getName));
And your done, just printing the objects (a toString method can be helpful here) you have the information sorted.
Edit: to read the input writing the questions, you just need to store the values in variables e.g.
System.out.println("What is track " + (i + 1));
String songName = scanner.nextLine();
System.out.println("How many thousands of times has it been downloaded? ");
int songDownloads = Integer.parseInt(scanner.nextLine());
arrayOfSongs[i] = new Song(songName, songDownloads);
Or you can just implement setter methods in the Song class and create a constructor with no parameters, so you can set the values as you are reading them.
thanks for the reply, so I've figured that i can use a for loop to ask the questions for song name and number of downloads. what im finding hard is putting their response in each array from 1-4 and saving dong name in the correct field of the song record and same for number of downloads?
public static void printmessage(song[] arrayOfSongs)
{
Scanner scanner = new Scanner(System.in);
int totalDownloads = 0;
for (int i = 0; i < arrayOfSongs.length; i++)
{
System.out.println("What is track " + (i + 1));
// store in array x name field
System.out.println("How many downloads does this track have? ");
//store in array x downloads field
}

how to go through a file with names and number scores and figure out who has first, second, third place

I'm having trouble with a problem. I can't figure out why my code is working incorrectly on this problem. The problem description is this -
Ask the user for the file name of the file they want to read from.
If a file is specified that is not available, throw an exception and output "File not found." and close the program.
Otherwise, open the specified file.
Each file will have a list of users' names and their (integer) high scores for the game.
Each line will have one name and one score. This is guaranteed - you don't have to plan for anything else.
Go through all of the users and determine who won first, second, and third place.
You can assume that each file will always have at least three names/scores.
The file I'm working with is a text file called Game1Winners. This is the content of the file:
Mario 58
Link 576
Bowser 354
Yoshi 798
Waluigi 39
Wario 521
Toadsworth 7
Pikachu 21
Luigi 243
This is my code but it's working incorrectly..It's printing out first place correctly, but second and third place are out of order..
import java.util.*;
import java.io.*;
public class HighScores
{
public static void main(String[] args)
{
Scanner kb = new Scanner(System.in);
System.out.print("What file? ");
String filename = kb.nextLine();
Scanner theFile = null;
try
{
theFile = new Scanner(new FileInputStream(filename));
}
catch(Exception e)
{
System.out.println("File not found.");
System.exit(0);
}
int score = 0;
int high_Score = 0;
int second_Place = 0;
int third_Place = 0;
String name = "";
String store1 = "";
String store2 = "";
String store3 = "";
while(theFile.hasNextLine())
{
name = theFile.next();
score = theFile.nextInt();
if(score > high_Score)
{
high_Score = score;
store1 = name + " with a score of " + high_Score;
}
if(score > second_Place && score < high_Score)
{
second_Place = score;
store2 = name + " with a score of " + second_Place;
}
if(score > third_Place && score < second_Place)
{
third_Place = score;
store3 = name + " with a score of " + third_Place;
}
}
System.out.println("First place: " + store1);
System.out.println("Second place: " + store2);
System.out.println("Third place: " + store3);
}
}

Java - Array outputing null

My program is supposed to output labels. All of the input works when I run it but the output is wrong and all that it outputs is null, for every part of the label except for the box number.
import javax.swing.JOptionPane;
public class MailOrderpractice {
static String nameAddressArray[] = new String[7];
public static void main(String[] args) {
// declare variables
String nameAddressArray[] = new String[7];
String numBoxesInput;
int numBoxes;
String enterAnother = "Y";
int counter;
getLabelData();
numBoxesInput = JOptionPane.showInputDialog("Enter number of boxes in the order:");
numBoxes = Integer.parseInt(numBoxesInput);
// begin outer loop logic that determines when user is finished entering mail orders
while (enterAnother.equalsIgnoreCase("Y")) {
counter = 1;
// begin the inner loop to display a label and increment the counter
while (counter <= numBoxes) {
System.out.println(nameAddressArray[0] + " " + nameAddressArray[1] + " " + nameAddressArray[2]);
System.out.println(nameAddressArray[3]);
System.out.println(nameAddressArray[4] + ", " + nameAddressArray[5] + " " + nameAddressArray[6]);
System.out.println("Box " + counter + " of " + numBoxes);
System.out.println();
counter = counter + 1;
}
enterAnother = " "; // initialize the variable to something other than "Y" before sending the prompt
enterAnother = JOptionPane.showInputDialog("Do you want to produce more labels? Y or N");
while (!enterAnother.equalsIgnoreCase("Y") && !enterAnother.equalsIgnoreCase("N")) {
enterAnother = JOptionPane.showInputDialog(null, "Invalid Response. Please enter Y or N.",
"DATA ENTRY ERROR", JOptionPane.ERROR_MESSAGE);
} // end while
if (enterAnother.equalsIgnoreCase("Y")) {
getLabelData();
numBoxesInput = JOptionPane.showInputDialog("Enter number of boxes in the order:");
numBoxes = Integer.parseInt(numBoxesInput);
} // end if
} // end while
System.exit(0);
}
public static void getLabelData() {
nameAddressArray[0] = JOptionPane.showInputDialog("Enter title (Mr., Ms., Dr., etc.): ");
nameAddressArray[1] = JOptionPane.showInputDialog("Enter first name: ");
nameAddressArray[2] = JOptionPane.showInputDialog("Enter lastname: ");
nameAddressArray[3] = JOptionPane.showInputDialog("Enter street address: ");
nameAddressArray[4] = JOptionPane.showInputDialog("Enter city: ");
nameAddressArray[5] = JOptionPane.showInputDialog("Enter state (IL, MO, etc.): ");
nameAddressArray[6] = JOptionPane.showInputDialog("Enter zip (e.g., 62025): ");
}
The array nameAddressArray is declared twice. You have a static field
static String nameAddressArray[] = new String[7];
You also have a local variable with the same name in the main method.
String nameAddressArray[] = new String[7];
Your main method is putting values into the second array, whereas your getLabelData method is using the values from the static field, and these are all the initial value (null).
One way to solve this problem is to just get rid of the local variable. Then both parts of the code will use the same array.
Alternatively, you could get rid of the static field, and pass the array as a parameter to the getLabelData method. This is probably a better solution, as mutable static fields are generally not a good idea.
you just need to comment this line into Main method(),
// String nameAddressArray[] = new String[7];

List and arraylist initialization and use

I'm attempting to create a list because of the ability to "add" and element as opposed to checking size then dynamically expanding an array every time a new element is input. I can't get this to compile. I've scoured stack and google and nothing I've found is helping me. Someone mentioned creating an array and using that to be added to the list, but it seems to me i should be able to do this without all that.
I'm trying to get the system to add a string to the list every time a certain result occurs.
For ease of finding the List is called "incorrect"
import java.text.DecimalFormat;
import java.util.*;
public class User{
private String wrongQuestion; //quiz question
private String userName; //store user name
private String myOutput; //store output for toString and file write
private int score; //store user current score
private float average; //store user average score
private int diffLevel; //difficulty level
private int testType; //last test type
private int numTests; //store number of tests taken
private List <String> incorrect; //declare list for incorrect answers
private FileIO uFile; //declare FileIO object
public User(String inName) throws Exception
{
//local constants
final int VARIABLE_COUNT = 5; //loop sentinel
final int TOKEN_SKIP = 4; //loop sentinel
//local variables
int index; //loop index
int count; //loop counter
String token; //store tokens from line
StringTokenizer tokenLine; //store tokenized line
//instantiate file object
uFile = new FileIO (inName);
//if user exists
if (uFile.checkUser())
{
for (count = 0; count < VARIABLE_COUNT; count++)
{
//initialize tokenized line
tokenLine = new StringTokenizer(uFile.readLine());
//try to store the variables
try
{
//get and store user average
//for the first 2 tokens, skip
for (index = 0; index < TOKEN_SKIP; index++)
{
//move to next token
token = tokenLine.nextToken();//end for
switch (count)
{
case 1:
//store number of tests taken
numTests = Integer.parseInt(token);
//end case
break;
case 2:
//store difficulty of last test taken
diffLevel = Integer.parseInt(token);
//end case
break;
case 3:
//store score of last test taken
score = Integer.parseInt(token);
//end case
break;
case 4:
//store average of tests taken
average = Integer.parseInt(token);
//end case
break;
default:
break;
}//end switch
}//end for
//store next line
token = uFile.readLine();
//while there are more lines in the file
while (token != null)
{
//instantiate list for incorrect answers
incorrect = new ArrayList<String>();
//add line to end of list
incorrect.get(token);
//store next line
token = uFile.readLine();
}//end while
}//end try
//catch input mismatch exception
catch (InputMismatchException error)
{
//output error message
System.out.println ("This file is not formatted properly." +
" Either continue as a new user or log in again");
//initialize data to 0
average = 0;
testType = 0;
diffLevel = 0;
numTests = 0;
incorrect = new ArrayList <String>();
}//end catch
}//end for
}//end if
else
{
//initialize data to 0
average = 0;
testType = 0;
diffLevel = 0;
numTests = 0;
incorrect = new ArrayList<String>();
}//end else
//close input stream
uFile.closeFileReader();
}//end constructor
public float calcAverage(int newScore)
{
//local constants
//local variables
float avg; //store temp average
/**************Begin calcAverage*********/
//recalibrate avg for new calculation
avg = 0;
//calculate new average test score
avg = ((average * numTests) + newScore )/(numTests + 1);
//return average to be stored
return avg;
}
public void updateUser(int newTestType, int newDiffLevel, int newScore)
{
//local constants
//local variables
/***************Begin updateUser************/
//update new data after test is taken
score = newScore;
average = calcAverage(newScore);
diffLevel = newDiffLevel;
testType = newTestType;
numTests = numTests + 1;
}
public void writeFile() throws Exception
{
//local constants
//local variables
String line; //current line to write to file
int index; //loop index
/*************************Begin writeFile***************/
//open output stream
uFile.openOutput(userName);
//write user name
line = "User Name:\t" + userName +"\n";
uFile.writeLine(line);
//write number of tests taken
line = "Tests Taken:\t" + numTests + "\n";
//write number of tests taken
line = "Difficulty Level:\t" + diffLevel + "\n";
uFile.writeLine(line);
//write score of last test taken
line = "Last Test:\t" + score + "\n";
uFile.writeLine(line);
//write current user average
line = "User Average:\t" + average + "\n";
uFile.writeLine(line);
//for each element in the list
for (index = 0; index < incorrect.size(); index++)
{
//store then write the string
line = incorrect.get(index);
uFile.writeLine(line);
}//end for
//close file writer
uFile.closeFileWrite();
}//end writeFile
public void storeIncorrect(String inString)
{
//local constants
//local variables
/************Begin storeIncorrect*************/
//add formatted question to the list
incorrect.add(inString);
}
public String toString()
{
//local constants
//local variables
String buildUserName;
String buildAvg;
String buildNumTests;
String buildDiffLevel;
String buildScore;
DecimalFormat fmt; //declare decimal format object
/****************Begin toString***********/
//initialize decimal format
fmt = new DecimalFormat ("0.00");
//build output strings
buildUserName = Util.setLeft(20, "User Name:") + Util.setRight(25, userName);
buildNumTests = Util.setLeft(20, "Tests Taken:") + Util.setRight(18, numTests+"");
buildDiffLevel = Util.setLeft(20, "Last Difficulty:") + Util.setRight(24, diffLevel+"");
buildScore = Util.setLeft(20, "Last Score:") + Util.setRight(24, score+"");
buildAvg = Util.setLeft(20, "Test Average:") + Util.setRight(24, fmt.format(average)+"");
myOutput = buildUserName + "\n" + buildNumTests + "\n" + buildDiffLevel + "\n" + buildScore + "\n" + buildAvg;
return myOutput;
}//Display all users info
}
Few comments that might help :
// add line to end of list
incorrect.get(token); // <- change this to incorrect.add(token)
To iterate thru list use :
for (String item : incorrect) {
System.out.printlnt(item);
}
Also, you don't need to reinitialize your list as you do multiple times by
incorrect = new ArrayList<String>();
If you'd like to clear it, you could use incorrect.clear()
As you are not interested in Random access (i.e. via index), perhaps you could use LinkedList instead of ArrayList

How to store multiple variables from a File Input of unknown size in Java?

I'm a total beginner with my first programming assignment in Java.
For our programming assignment, we will be given a .txt file of students like so:
My problem is: I have a specific class for turning the data from the file into variables to be used for a different class in printing it to the screen. However, I do not know of a good way to get the variables from the input file for the course numbers, since that number is not predetermined. The only way I can think of to iterate over that unknown amount is using a loop, but that would just overwrite my variables every time. Also, the teacher has requested that we not use any JCL classes (I don't really know what this means.)
Sorry if I have done a poor job of explaining this, but I can't think of a better way to conceptualize it. Let me know if I can clarify.
Edit:
public static void analyzeData()
{
Scanner inputStream = null;
try
{
inputStream = new Scanner(new FileInputStream("Programming Assignment 1 Data.txt"));
}
catch (FileNotFoundException e)
{
System.out.println("File Programming Assignment 1 Data.txt could not be found or opened.");
System.exit(0);
}
int numberOfStudents = inputStream.nextInt();
int tuitionPerHour = inputStream.nextInt();
String firstName = inputStream.next();
String lastname = inputStream.next();
String isTuitionPaid = inputStream.next();
int numberOfCourses = inputStream.nextInt();
String courseName = inputStream.next();
String courseNumber = inputStream.next();
int creditHours = inputStream.nextInt();
String grade = inputStream.next();
To show the methods I am using now, I am just using a Scanner to read from the file and for Scanner inputStream, I am using nextInt() or next() to get variables from the file. Obviously this will not work when I do not know exactly how many classes each student will have.
Create a Class called Student
Inside the class use instance variable like
String firstName;
String lastname;
Boolean isTuitionPaid; // Boolean cause isPaid will be true or false
String[] courses;
int creditHours;
String grade;
Create a constructor of this class which takes the following arguments in its parameter
Student( String fName,String lName,Boolean istPaid,String[] course,int cHours,String gr)
When you read the data of a student from a file, store it in the appropriate data type, as mentioned in the constructor, then create the Object of type Student
After creating the Student object with the data, store it an appropriate Collection.
ArrayList, Map, etc
parse the file, create a POJO (lets call it model) and store it in the appropriate collection (possibly an implementation of List would do it). BTW nobody would solve homework, I believe this is a policy here.
Maybe this would help:
public static void analyzeData()
{
try
{
Scanner inputStream = new Scanner(new FileInputStream("Programming Assignment 1 Data.txt"));
String str = inputStream.next();
String[] s = str.split(" ");
int numberOfStudents = Integer.parseInt(s[0]);
int tuitionPerHour = Integer.parseInt(s[1]);
System.out.println("Number of students: " + numberOfStudents);
System.out.println("Tuition per hour: " + tuitionPerHour + "\n\n");
for(int i = 0; i<numberOfStudents; i++)
{
String str1 = inputStream.next();
String[] s1 = str1.split(" ");
String firstName = s1[0];
String lastName = s1[1];
int rollNo = Integer.parseInt(s1[2]);
String isTuitionPaid = s1[3];
int numberOfCourses = Integer.parseInt(s1[4]);
System.out.println("Details of student number " + (i+1));
System.out.println("Name: " + firstName + " " + lastName);
System.out.println("Roll No: " + rollNo);
System.out.println("Is Tuition paid: " + (isTuitionPaid == "Y" ? "Yes" : "No"));
System.out.println("Number of Courses taken: " + numberOfcourses + "\n");
for(int j = 0; j<numberOfCourses; j++)
{
System.out.println("Details of course no " + (j+1));
String str2 = inputStream.next();
String[] s2 = str2.split(" ");
String courseName = s2[0];
String courseNumber = s2[1];
int creditHours = Integer.parseInt(s2[2]);
String grade = s2[3];
System.out.println("Course Name: " + courseName);
System.out.println("Course Number: " + courseNumber);
System.out.println("Credit Hours: " + creditHours);
System.out.println("Grade: " + grade + "\n");
}
}
}
catch (FileNotFoundException e)
{
System.out.println("File Programming Assignment 1 Data.txt could not be found or opened.");
e.printStackTrace();
System.exit(0);
}
catch(IOException ioe)
{
System.out.err("IOException has occurred");
ioe.printStackTrace();
System.exit(0);
}
catch(Exception e)
{
e.printStackTrace();
}
}

Categories