Program 1 |
| Unsorted Array | 34 | 28 | 43 | 15 |
| compare and swap | 28 | 34 | 43 | 15 |
| compare | 28 | 34 | 43 | 15 |
| compare and swap | 28 | 34 | 15 | 43 |
| compare | 28 | 34 | 15 | 43 |
| compare and swap | 28 | 15 | 34 | 43 |
| compare | 28 | 15 | 34 | 43 |
| compare and swap | 15 | 28 | 34 | 43 |
| Sorted Array | 15 | 28 | 34 | 43 |
Program 2 |
Program 3 |
|
James Baca Computer Science Julia Swetson History Tilda Pravishtar Chemistry James Baker Biology Roger Childs English Studies |
|
Data read from the file .... James Baca : Computer Science Julia Swetson : History Tilda Pravishtar : Chemistry James Baker : Biology Roger Childs : English Studies Names sorted by length (smallest to largest) .... James Baca : Computer Science James Baker : Biology Roger Childs : English Studies Julia Swetson : History Tilda Pravishtar : Chemistry |
// INPUT FILE AND SCANNER THAT READS THE FILE
File inputFile;
Scanner fileInputScan = null;
PrintWriter out = null;
try {
// INSTANTIATE A FILE SCANNER AND LINK IT TO THE INPUT FILE
// UNIX PATHWAY : "/Users/TrishCornez/Desktop/fileI.txt"
// WINDOWS PATHWAY: "C:\\Users\\patricia_cornez\\Desktop\\fileI.txt
inputFile = new File("C:\\Users\\patricia_cornez\\Desktop\\fileI.txt");
fileInputScan = new Scanner(inputFile);
//INSTANTIATE AN OUTPUT FILE STREAM AND LINK IT TO THE OUTPUT FILE
out = new PrintWriter("C:\\Users\\patricia_cornez\\Desktop\\fileO.txt");
// OUTPUT HELLO WORLD TO THE OUTPUT FILE
out.print("Hello World");
} catch (FileNotFoundException e) {
System.out.println("Error - This file could not be found.");
} finally {
if (fileInputScan != null)
fileInputScan.close();
if (out != null)
out.close();
}