Could someone help me please? Thank you 1.) /** * Calculates the tuition for eac
ID: 639597 • Letter: C
Question
Could someone help me please? Thank you
1.) /**
* 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) {
//write your code here
2.) /**
* 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) {
//write your code here
}
3.)/**
* 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
*/
private void writeFile(ArrayList<Student> pStudentList) throws FileNotFoundException {
Requirements:
Student information is stored in a text file named p02-students.txt. There is one student record per line, where the format of a student record for an on-campus student is:
C id last-name first-name residency program-fee credits where:
'C'
id last-name first-name residency program-fee credits
Identifies the student as an on-campus student.
The student identifier number. A string of 13 digits.
The student's last name. A contiguous string of characters.
The student's first name. A contiguous string of characters.
'R' if the student is a resident, 'N' if the student is a non-resident. A program fee, which may be zero.
The number of credit hours for which the student is enrolled.
The format of a student record for an online student is:
O id last-name first-name tech-fee credits
where 'O' identifies the student as an online student, and id, last-name, first-name, and credits are the same as for an on-campus student. The tech-fee field is 'T' if the student is to be assessed the technology fee or '-' if the student is not assessed the technology fee.
Explanation / Answer
This program will calculate the total tuition and fees for students import javax.swing.*; import java.text.*; public class Tuition { public static String dialogTitle = "Tuition and Fees Calculator"; //want dialogTitle to be the same for most dialogs //ensure newline is cross-platform. Taken from http://leepoint.net/notes-java/io/10file/sys-indep-newline.html public static String newline = System.getProperty("line.separator"); //main method overloading; for restarting app public static void main(String[] args) { main(""); } //overloaded main method. was easier for me to check for a null string than it was to check for a null string array. public static void main(String args) { int hours; double fees, rate, tuition; if (args == "") displayWelcome(); //display welcome message unless arguments are passed in hours = getHours(); //ask user for number of hours rate = getRate(hours); //get the cost per credit hour rate tuition = calcTuition(hours, rate); //calculate the tuition fees = calcFees(tuition); //calculate the fees displayTotal(tuition + fees); //display the result to the user finish(""); //user is finished, end the program (without asking) } //display the welcome message to the user public static void displayWelcome() { String welcomeMsg = "Welcome to the Tuition and Fees calculator!"; JOptionPane.showMessageDialog(null, welcomeMsg, dialogTitle, JOptionPane.PLAIN_MESSAGE); } //ask the user for number of hours public static int getHours() { String strHours, askHours; int hours = 0; boolean done = false; askHours = "Please enter the total number of course hours the student will be attending:"; //continue asking user until user provides valid input while (!done) { strHours = JOptionPane.showInputDialog(null, askHours, dialogTitle, JOptionPane.QUESTION_MESSAGE); if (strHours == null) {finish("ask");} //user cancelled the dialog. ask if user is sure before quitting. else { try { hours = Integer.parseInt(strHours); if (hoursRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.