my final


#1

import java.io.File;

import java.io.FileNotFoundException;

import java.io.IOException;

import java.io.PrintWriter;

import java.util.ArrayList;

import java.util.Arrays;

import java.util.HashSet;

import java.util.Scanner;

import java.util.Set;

public class LetterGrader {

Scanner input = new Scanner(System. in );

String line = input.nextLine();

String studentInfo = line.split(",");

public LetterGrader(String string, String string2) {

}

public static void main(String args) {

if (args.length < 2) {

System. out .println(“Usage: java Final inputFlile outputFile”);

System. exit (1);

} else {

System. out .println("Input will be read from: " + args[0] + "\nOutput will be written into: " + args[1]);

System. out .println();

}

File inputFile = new File(args[0]);

if (!inputFile.exists()) {

System. out .println(“Input file " + args[0] + " does not exist”);

System. exit (2);

}

File outputFile = new File(args[1]);

processCLArguments (args);

processInputOutputFiles (args);

}

static void processCLArguments(String args) {

// proceed because you found two arguments

// check if user gave the command line arguments

}

static void processInputOutputFiles(String args) {

// call method to process command line arguments

File inputFile = new File(args[0]);

// Output file

File outputFile = new File(args[1]);

try {

// Create input and output files

Scanner input = new Scanner(inputFile);

PrintWriter output = new PrintWriter(outputFile);

int i = 1;

while (input.hasNextLine()) {

String line = input.nextLine();

// display the whole line on screen

System. out .println("Student #: " + i + " " + line);

ArrayList<String> s_list = new ArrayList<>();

s_list.add(line);

int n = s_list.size();

n++;

System. out .println("n is " + n);

// this line has one students date

// use split

String studentInfo = line.split(",");

// write the data in output file

output.print(“Student #” + i++ + " is: “” + studentInfo[0] + “” whose raw scores are : ");

for ( int j = 1; j < studentInfo.length; j++)

output.print(studentInfo[j] + "# ");

output.println();

}

input.close();

output.close();

} catch (IOException e) {

System. out .println("Error reading from input file: " + args[0]);

}

}

void readScore() {

this .readScore();

}

void readScore(String args) {

File inputFile = new File(args[0]);

if (!inputFile.exists()) {

System. out .println(“Input file " + args[0] + " does not exist”);

System. exit (2);

}

// reads score and stores the data in member variables

}

private void readScore(String name, int scores) {

}

void calcLetterGrade() {

// determines letter grade and stores information

//String studentInfo = null;

double finalscore = 0;

while (input.hasNextLine()) {

String line = input.nextLine();

String studentInfo = line.split(",");

finalscore = Integer. parseInt (studentInfo[1]) * 0.10 + Integer. parseInt (studentInfo[2]) * 0.10

  • Integer. parseInt (studentInfo[3]) * 0.10 + Integer. parseInt (studentInfo[4]) * 0.10

  • Integer. parseInt (studentInfo[5]) * 0.20 + Integer. parseInt (studentInfo[6]) * 0.25

  • Integer. parseInt (studentInfo[7]) * 0.25;

if (finalscore >= 90.0)

System. out .print(studentInfo[0] + “A”);

else if (finalscore >= 80.0)

System. out .print(studentInfo[0] + “B”);

else if (finalscore >= 70.0)

System. out .print(studentInfo[0] + “C”);

else if (finalscore >= 60.0)

System. out .print(studentInfo[0] + “D”);

else

System. out .print(studentInfo[0] + “F”);

Arrays. sort (studentInfo);

}

// try to count in ArrayList

ArrayList<String> s_list = new ArrayList<>();

s_list.add(line);

int n = s_list.size();

n++;

System. out .println("n is " + n);

int sum = 0;

for ( int i = 0; i <=7; i++) {

sum += Integer. parseInt (studentInfo[i]);

}

double average = 0;

average = sum / n;

int max = -1;

int min = Integer. MAX_VALUE ;

}

void printGrade() {

// writes the grade in output file

/*if (studentInfo[0].compareTo(studentInfo[0]) > 0) {

String temp = studentInfo[0];

studentInfo[0] = studentInfo[0];

studentInfo[0] = temp;

}*/

}

void diplayAverages() {

// display the averages in console

System. out .printf("%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s\n", “”, “Q1”, “Q2”, “Q3”,“Q4”,“Mid1”,“Mid2”,“Final”);

System. out .printf("%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s\n", “Average”);//, average++);

System. out .printf("%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s\n", “Minimum”);//, min++);

System. out .printf("%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s\n", “Maximum”);//, max++);

}

void doCleanup() {

// use is to close files and other resources

input.close();

output.close();

}

}