Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Your program should be submitted to blackboard. Your submitted program will be a

ID: 3737372 • Letter: Y

Question

Your program should be submitted to blackboard. Your submitted program will be assigned a grade based on the correctness of your program and evaluation of your program.

Programming Standards:

You'll be expected to observe good programming and documentation standards. All the discussions in class about formatting, structure, and commenting your code will be enforced. Your project will be evaluated using the standards below:

Correctness and completeness of your program (65 points)

Presentation (20 points)

Peer-evaluation assignment (individual, 5 points)

You must include header comments specifying your group name, and the date your source code and documentation were completed. The header comment must also include a brief description of the purpose of the program or method (sort of a user guide) — this should be in your own words, not copied from this specification. You must include a comment explaining the purpose of every variable you use in your program. Precede every major block of your code with a comment explaining its purpose. (10 points)


Code Example:

public class Project1 {
    /*************************************************************************
    * Project 1 for IT501
    * Temperature Converter Program
    *
    * Programmer: Group1
    * Last modified: September 11, 2016
    *
    * Purpose: This program takes input from a file named "celsius_in.txt",
    *      which contains five lines, each containing a single decimal
    *      value representing a temperature in the Celsius scale.
    *      This program converts those five temperatures to Fahrenheit
    *      scale, and sends results to a file called "fahrenheit_out.txt".

    ***********************************************************************/
    public static void main(String args[]) throws Exception{
        // String objects holding the input and output filenames
        String myInFileName = "celsius_in.txt";
        String myOutFileName = "fahrenheit_out.txt";
        // decimal Celsius temperatures, as determined from input
        double cTemp1, cTemp2, cTemp3, cTemp4, cTemp5;

        // determine output messages from the temperature values
msg1 = generateMsg(cTemp1);
        // output the result
myOutput.println("Programmer: group1");
myOutput.println();
     }}

Project 1: Progress Report (Group1 &Group2)


Requirements description:


First, this program reads courses students have completed from a file, called " Courses completed.txt", which holds five students' info, then this program should:

1. calculates and output the GPA of each students

Grade of each course will be based on the following elements and the grading scale provided below:

Numeric

Grade

Numeric

Grade

Over 94

A

74 to 76.9

C

90 to 93.9

A-

70 to 73.9

C-

87 to 89.9

B+

67 to 69.9

D+

84 to 86.9

B

64 to 66.9

D

80 to 83.9

B-

60 to 63.9

D-

77 to 79.9

C+

<60

F

Note: A: 4.0 A-:3.7 B+:3.3 B:3 B-:2.7 C+:2.3   C:2 C-:1.7 D+:1.3 D:1 D-:0.7 F: 0

2. based on the program plan (all courses students need to take) in “courses needed.txt”, output courses each student needs to take in the future.

A sample output is as follows:

Tom’s current GPA is 3.75

The courses he needs to take are:

FOUNDATION COURSES:

MBA 503 Foundations of Business Statistics;

IT 501 Fundamentals of Java Programming;

CORE COURSES:

IT 510 Information Technology Management;

IT 511 Data Management;

IT 514 Web Development;

IT 515 Data Warehousing;

IT 516 Social Media Analytics;

IT 517 Big Data Analytics;

Design requirements:

1. The program should be able to calculate and output GPA of each student

2. The program should be able to output courses students need to take in the future based on their records in “course completed” file. Foundation courses and core courses should be listed separately.

Courses Required

FOUNDATION COURSES:

MBA 500 Advanced Academic and Professional Practices;

MBA 503 Foundations of Business Statistics;

IT 500 Business Analytics;

IT 501 Fundamentals of Java Programming;

CORE COURSES:

IT 510 Information Technology Management;

IT 511 Data Management;

IT 512 Project Management;

IT 513 Information Security;

IT 514 Web Development;

IT 515 Data Warehousing;

IT 516 Social Media Analytics;

IT 517 Big Data Analytics;

Courses Taken

Numeric

Grade

Numeric

Grade

Over 94

A

74 to 76.9

C

90 to 93.9

A-

70 to 73.9

C-

87 to 89.9

B+

67 to 69.9

D+

84 to 86.9

B

64 to 66.9

D

80 to 83.9

B-

60 to 63.9

D-

77 to 79.9

C+

<60

F

Explanation / Answer

package January;

import java.io.BufferedReader;

import java.io.*;

import java.io.FileNotFoundException;

import java.io.FileReader;

import java.io.IOException;

// Class CourseSuggest definition

public class CourseSuggest

{

// Creates a string array to store foundation courses available

String foundationCourse[] = {"MBA 500 Advanced Academic and Professional Practices",

"MBA 503 Foundations of Business Statistics",

"IT 500 Business Analytics",

"IT 501 Fundamentals of Java Programming"};

// Creates a string array to store core courses available

String coreCourse [] = {"IT 510 Information Technology Management", "IT 511 Data Management",

"IT 512 Project Management", "IT 513 Information Security", "IT 514 Web Development",

"IT 515 Data Warehousing", "IT 516 Social Media Analytics", "IT 517 Big Data Analytics"};

// String array to store student name

String studentName[];

// String matrix to store foundation course names

String courseNameFoundation[][];

// String matrix to store core course names

String courseNameCore[][];

// Counter for course type

int courseCounterType [][];

// To store GPA

double GPA[];

// To store number of students

int numberOfStudents;

// Counter for foundation and core course

int courseCounterF = 0;

int courseCounterC = 0;

// Dynamically allocates memory to an integer array based of the foundationCourse length

// To store the foundation course match index position

int posf[] = new int[foundationCourse.length];

// Dynamically allocates memory to an integer array based of the coreCourse length

// To store the core course match index position

int posc[] = new int[coreCourse.length];

// Method to read file contents

void readFile(String filename)

{

// Initializes number of students to one

numberOfStudents = 1;

// To handle exception

try

{

// Creates BufferedReader object to read file contents

BufferedReader br = new BufferedReader(new FileReader(filename));

// Read the contents of file

String contentLine = br.readLine();

// Reads the contents of the file till null

while (contentLine != null)

{

// Checks if the first character is '-'

if(contentLine.charAt(0) == ('-'))

// Increase the number of students counter by one

numberOfStudents++;

// Read the contents of file

contentLine = br.readLine();

}// End of while loop

// Close the file

br.close();

// Reopens the file

br = new BufferedReader(new FileReader(filename));

// Dynamically allocates memory based on number of students

studentName = new String[numberOfStudents];

courseNameFoundation = new String[numberOfStudents][];

courseNameCore = new String[numberOfStudents][];

courseCounterType = new int[numberOfStudents][2];

GPA = new double[numberOfStudents];

// Loops till number of students

for(int x = 0; x < numberOfStudents; x++)

{

// Dynamically allocates memory to column

courseNameFoundation[x] = new String[100];

courseNameCore[x] = new String[100];

}// End of for loop

// Re initializes the counter to zero

numberOfStudents = 0;

// Counter to check name

int c = 0;

// Index position for course and GPA

int courseIndex, GPAIndex;

// Reads the contents of the file till null

do

{

// Read the contents of file

contentLine = br.readLine();

// Checks if the content is null then stop

if(contentLine == null)

break;

// Checks if the first character is '-'

if(contentLine.charAt(0) == ('-'))

{

// Increase the number of students counter by one

numberOfStudents++;

// Reset the name counter to zero for reading name

c = 0;

// Resets the counter for foundation and core course to zero for next student

courseCounterF = 0;

courseCounterC = 0;

// Read the contents of file

contentLine = br.readLine();

}// End of if condition

// Checks if the c value is zero which is for reading student name

if(c == 0)

{

// Stores the student name at index position numberOfStudents

studentName[numberOfStudents] = contentLine;

// Increase the counter by one

c++;

}// End of if condition

// Otherwise c is not zero which is for course contents

else

{

// Loops till length of the read string

for(courseIndex = 0; courseIndex < contentLine.length(); courseIndex++)

// Extracts the index position of the symbol ':'

if(contentLine.charAt(courseIndex) == ':')

break;

// Loops till length of the read string

for(GPAIndex = 0; GPAIndex < contentLine.length(); GPAIndex++)

// Extracts the index position of the symbol ';'

if(contentLine.charAt(GPAIndex) == ';')

break;

// Checks if the index is not -1 for found

if(courseIndex != -1)

{

// Extracts string from zero index position to the value of index from contentLine

// Stores it as course name

String course = contentLine.substring(0, courseIndex);

// Loops till length of the string array foundationCourse

// To validate foundation course is available

for(int x = 0; x < foundationCourse.length; x++)

// Checks the extracted course name

// with each index position of the string array foundationCourse  

if(course.equalsIgnoreCase(foundationCourse[x]))

// Stores the course name

// for numberOfStudents as row

// CourseCounterF for column of foundation course counter

courseNameFoundation[numberOfStudents][courseCounterF++] = course;

// Updates the courseCounterType counter for number of foundation courses

// for each student

courseCounterType[numberOfStudents][0] = courseCounterF;

// To validate core course is available

for(int x = 0; x < coreCourse.length; x++)

// Checks the extracted course name

// with each index position of the string array coreCourse

if(course.equalsIgnoreCase(coreCourse[x]))

// Stores the course name

// for numberOfStudents as row

// CourseCounterC for column of core course counter

courseNameCore[numberOfStudents][courseCounterC++] = course;

// Updates the courseCounterType counter for number of core courses

// for each student

courseCounterType[numberOfStudents][1] = courseCounterC;

}// End of if condition

// Checks if GPAIndex is not -1 then found

if(GPAIndex != -1)

// Extracts the GPA, converts it to double

// Calculates percentage

// Adds GPA

GPA[numberOfStudents] += Double.parseDouble(contentLine.substring(courseIndex+1, GPAIndex))/100.0;

}// End of else

}while (contentLine != null); // End of do - while loop

}// End of try block

// Handles file not found exception

catch (FileNotFoundException e)

{

System.out.println("Unable to open the file " + filename);

}// End of catch

// Handles input output exception

catch (IOException e)

{

System.out.println(e);

}// End of catch

}// End of method

// Method to display information

void displayOutput()

{

// Loops till number of students

for(int c = 0; c < numberOfStudents; c++)

{

// Displays name and GPA

System.out.printf(" %s's current GPA is %.2f", studentName[c], GPA[c]);

System.out.printf(" The courses he needs to take are:");

// Displays foundation course suggestion

System.out.printf(" FOUNDATION COURSES: ");

// Loops till number of course of type foundation which is store at 0 index position

for(int x = 0; x < courseCounterType[c][0]; x++)

{

// Loops till the length of string array foundationCourse

for(int d = 0; d < foundationCourse.length; d++)

{

// Checks if the student at c index position and its course at x index position

// is equals to the string array foundationCourse d index position

if(courseNameFoundation[c][x].equalsIgnoreCase(foundationCourse[d]))

// Set the array posf index position d to 1 for foundation course type

posf[d] = 1;

}// End of inner for loop

}// End of outer for loop

// Loops till length of the posf

for(int x = 0; x < posf.length; x++)

// Checks if the current index position value is not one

if(posf[x] != 1)

// Display the foundationCourse name

System.out.printf(" %s", foundationCourse[x]);

// Displays core course suggestion

System.out.printf(" CORE COURSES:");

// Loops till number of course of type core, which is store at 1 index position

for(int x = 0; x < courseCounterType[c][1]; x++)

{

// Loops till the length of string array coreCourse

for(int d = 0; d < coreCourse.length; d++)

{

// Checks if the student at c index position and its course at x index position

// is equals to the string array coreCourse d index position

if(courseNameCore[c][x].equalsIgnoreCase(coreCourse[d]))

// Set the array posc index position d to 1 for core course type

posc[d] = 1;

}// End of inner for loop

}// End of outer for loop

// Loops till length of the posc

for(int x = 0; x < posc.length; x++)

// Checks if the current index position value is not one

if(posc[x] != 1)

// Display the coreCourse name

System.out.printf(" %s", coreCourse[x]);

// Reset the foundation and core course count found position array each index position to zero

for(int x = 0; x < posf.length; x++)

posf[x] = 0;

for(int x = 0; x < posc.length; x++)

posc[x] = 0;

}// End of loop for number of students

}// End of method

// Method to write the contents to file

void writeFile(String fileName)

{

// Creates a File object

File file = new File(fileName);

// Declares a FileWriter object

FileWriter fr = null;

// try block begins

try

{

// Initializes FileWriter object

fr = new FileWriter(file);

// Loops till number of students

for(int c = 0; c < numberOfStudents; c++)

{

// Writes student name and GPA

fr.write(studentName[c] + "'s current GPA is " + GPA[c]);

fr.write(" ");

// Loops till length of the posf

for(int x = 0; x < posf.length; x++)

{

// Checks if the current index position value is not one

if(posf[x] != 1)

{

// Writes foundation course names to file

fr.write(foundationCourse[x]);

fr.write(" ");

}// End of if condition

}// End of inner for loop

// Loops till length of the posc

for(int x = 0; x < posc.length; x++)

{

// Checks if the current index position value is not one

if(posc[x] != 1)

{

// Writes core course names to file  

fr.write(coreCourse[x]);

fr.write(" ");

}// End of if condition

}// End of inner for loop

}// End of outer for loop

} // End of try block

// Catch block to handle exception

catch (IOException e)

{

e.printStackTrace();

}// End of catch block

// finally block

finally

{

//close resources

try

{

fr.close();

}

catch (IOException e)

{

e.printStackTrace();

}

}// End of finally block

}// End of method

// main method definition

public static void main(String[] args)

{

// Creates an object of CourseSuggest

CourseSuggest cs = new CourseSuggest();

// Calls the method to read file contents

cs.readFile("CoursesCompleted.txt");

// Display the contents

cs.displayOutput();

cs.writeFile("CoursesNeeded.txt");

}// End of main method

}// End of class

Sample Output:

Tom's current GPA is 3.69
The courses he needs to take are:
FOUNDATION COURSES:

MBA 503 Foundations of Business Statistics
IT 501 Fundamentals of Java Programming
CORE COURSES:
IT 510 Information Technology Management
IT 511 Data Management
IT 514 Web Development
IT 515 Data Warehousing
IT 516 Social Media Analytics
IT 517 Big Data Analytics

Tim's current GPA is 3.46
The courses he needs to take are:
FOUNDATION COURSES:

MBA 500 Advanced Academic and Professional Practices
CORE COURSES:
IT 510 Information Technology Management
IT 511 Data Management
IT 512 Project Management
IT 513 Information Security
IT 514 Web Development
IT 515 Data Warehousing
IT 517 Big Data Analytics

Smith's current GPA is 1.99
The courses he needs to take are:
FOUNDATION COURSES:

MBA 500 Advanced Academic and Professional Practices
IT 500 Business Analytics
IT 501 Fundamentals of Java Programming
CORE COURSES:
IT 510 Information Technology Management
IT 511 Data Management
IT 513 Information Security
IT 514 Web Development
IT 515 Data Warehousing
IT 516 Social Media Analytics
IT 517 Big Data Analytics

Davis's current GPA is 3.44
The courses he needs to take are:
FOUNDATION COURSES:

MBA 500 Advanced Academic and Professional Practices
IT 500 Business Analytics
CORE COURSES:
IT 511 Data Management
IT 512 Project Management
IT 513 Information Security
IT 514 Web Development
IT 515 Data Warehousing
IT 516 Social Media Analytics