Calculates the tuition for each student write an enhanced


I have bene unable to complete the following project and need help to complet it.

//***********************************************

// CLASS: Main

//

// DESCRIPTION

// The Main class for Project 2.

//

// AUTHOR

// Kevin R. Burger ([email protected])

// Computer Science & Engineering

// School of Computing, Informatics, and Decision Systems Engineering

// Fulton Schools of Engineering

// Arizona State University, Tempe, AZ 85287-8809

// Web: https://www.devlang.com

//**************************************************

import java.io.File;

import java.io.FileNotFoundException;

import java.io.PrintWriter;

import java.util.ArrayList;

import java.util.Scanner;
public class Main {
/**

* Instantiate a Main object and call run() on the object.

*/

public static void main(String[] args) {

???

}
/**

* Calculates the tuition for each student. Write an enhanced for loop that iterates over each Student in

* pStudentList. For each Student, call calcTuition() on that Student. Note: this is a polymorphic method

* call.

*

* PSEUDOCODE

* EnhancedFor each student in pStudentList Do

* student.calcTuition()

* End EnhancedFor

*/

private void calcTuition(ArrayList pStudentList) {

???

}
/**

* Reads the student information from "p02-students.txt" and returns the list of students as an ArrayList

* object.

*

* PSEUDOCODE

* Declare and create an ArrayList object named studentList.

* Open "p02-students.txt" for reading using a Scanner object named in.

* While in.hasNext() returns true Do

* String studentType <- read next string from in

* If studentType is "C" Then

* studentList.add(readOnCampusStudent(in))

* Else

* studentList.add(readOnlineStudent(in))

* End If

* End While

* Close the scanner

* Return studentList

*/

private ArrayList readFile() throws FileNotFoundException {

???

}
/**

* Reads the information for an on-campus student.

*

* PSEUDOCODE

* Declare String object id and assign pIn.next() to id

* Declare String object named lname and assign pIn.next() to lname

* Declare String object named fname and assign pIn.next() to fname

* Declare and create an OnCampusStudent object. Pass id, fname, and lname as params to ctor.

* Declare String object named res and assign pIn.next() to res

* Declare double variable named fee and assign pIn.nextDouble() to fee

* Declare int variable named credits and assign pIn.nextInt() to credits

* If res.equals("R") Then

* Call setResidency(true) on student

* Else

* Call setResidency(false) on student

* End If

* Call setProgramFee(fee) on student

* Call setCredits(credits) on student

* Return student

*/

private OnCampusStudent readOnCampusStudent(Scanner pIn) {

???

}
/**

* Reads the information for an online student.

*

* PSEUDOCODE

* Declare String object id and assign pIn.next() to id

* Declare String object named lname and assign pIn.next() to lname

* Declare String object named fname and assign pIn.next() to fname

* Declare and create an OnlineStudent object. Pass id, fname, lname as params to the ctor.,

* Declare String object named fee and assign pIn.next() to fee

* Declare int variable named credits and assign pIn.nextInt() to credits

* If fee.equals("T")) Then

* Call setTechFee(true) on student

* Else

* Call setTechFee(false) on student

* End If

* Call setCredits(credits) on student

* Return student

*/

private OnlineStudent readOnlineStudent(Scanner pIn) {

???

}
/**

* Calls other methods to implement the sw requirements.

*

* PSEUDOCODE

* Declare ArrayList object named studentList

* try

* studentList = readFile()

* calcTuition(studentList)

* Call Sorter.insertionSort(studentList, Sorter.SORT_ASCENDING) to sort the list

* writeFile(studentList)

* catch FileNotFoundException

* Print "Sorry, could not open 'p02-students.txt' for reading. Stopping."

* Call System.exit(-1)

*/

private void run() {

???

}
/**

* Writes the output file to "p02-tuition.txt" per the software requirements.

*

* PSEUDOCODE

* Declare and create a PrintWriter object named out. Open "p02-tuition.txt" for writing.

* EnhancedFor each student in pStudentList Do

* out.print(student id + " " + student last name + " " + student first name)

* out.printf("%.2f%n" student tuition)

* End EnhancedFor

* Close the output file

*/

private void writeFile(ArrayList pStudentList) throws FileNotFoundException {

???

}

}

 

//**************************************************************************************************************

// CLASS: Sorter

//

// DESCRIPTION

// Implements the insertion sort algorithm to sort an ArrayList<> of Students.

//

// AUTHOR

// Kevin R. Burger ([email protected])

// Computer Science & Engineering Program

// Fulton Schools of Engineering

// Arizona State University, Tempe, AZ 85287-8809

// http:www.devlang.com

//**************************************************************************************************************

package tuition;
import java.util.ArrayList;
public class Sorter {
public static final int SORT_ASCENDING = 0;

public static final int SORT_DESCENDING = 1;
/**

* Sorts pList into ascending (pOrder = SORT_ASCENDING) or descending (pOrder = SORT_DESCENDING) order

* using the insertion sort algorithm.

*/

public static void insertionSort(ArrayList pList, int pOrder) {

for (int i = 1; i < pList.size(); ++i) {

for (int j = i; keepMoving(pList, j, pOrder); --j) {

swap(pList, j, j - 1);

}

}

}
/**

* Returns true if we need to continue moving the element at pIndex until it reaches its proper location.

*/

private static boolean keepMoving(ArrayList pList, int pIndex, int pOrder) {

if (pIndex < 1) return false;

Student after = pList.get(pIndex);

Student before = pList.get(pIndex - 1);

return (pOrder == SORT_ASCENDING) ? after.compareTo(before) < 0 : after.compareTo(before) > 0;

}
/**

* Swaps the elements in pList at pIndex1 and pIndex2.

*/

private static void swap(ArrayList pList, int pIndex1, int pIndex2) {

Student temp = pList.get(pIndex1);

pList.set(pIndex1, pList.get(pIndex2));

pList.set(pIndex2, temp);

}
}

//**************************************************************************************************************

// CLASS: TuitionConstants

//

// DESCRIPTION

// Constants that are used in calculating the tuition for on-campus and online students. Use these constants

// in the OnCampusStudent and OnlineStudent classes.

//

// AUTHOR

// Kevin R. Burger ([email protected])

// Computer Science & Engineering

// School of Computing, Informatics, and Decision Systems Engineering

// Fulton Schools of Engineering

// Arizona State University, Tempe, AZ 85287-8809

// Web: https://www.devlang.com

//**************************************************************************************************************

package tuition;
public class TuitionConstants {
public static final int ONCAMP_ADD_CREDITS = 350;

public static final int MAX_CREDITS = 18;

public static final int ONCAMP_NONRES_BASE = 12200;

public static final int ONCAMP_RES_BASE = 5500;

public static final int ONLINE_CREDIT_RATE = 875;

public static final int ONLINE_TECH_FEE = 125;
}

Attachment:- Attachments.rar

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Calculates the tuition for each student write an enhanced
Reference No:- TGS01365057

Expected delivery within 24 Hours