Write an enhanced for loop that iterates over each student

Assignment Help JAVA Programming
Reference no: EM131018072

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 (burgerk@asu.edu)

// Computer Science & Engineering

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

// Fulton Schools of Engineering

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

// Web: http://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<Student> pStudentList) {

???

}
/**

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

* <Student> object.

*

* PSEUDOCODE

* Declare and create an ArrayList<Student> 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<Student> 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<Student> 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<Student> pStudentList) throws FileNotFoundException {

???

}

}

 

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

// CLASS: Sorter

//

// DESCRIPTION

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

//

// AUTHOR

// Kevin R. Burger (burgerk@asu.edu)

// 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<Student> 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<Student> 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<Student> 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 (burgerk@asu.edu)

// Computer Science & Engineering

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

// Fulton Schools of Engineering

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

// Web: http://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;
}

Reference no: EM131018072

Java program that will add the corresponding elements

Develop a Java program that will add the corresponding elements of two 1-dimensional arrays X and Y to produce the 1-dimensional array Z. Arrays X, Y, Z have the same dimens

Java data structures

Project is to create a German-English, English-German, French-English, English-French dictionary. You will be responsible for entering a total of twenty-five words in German,

Write the logical expression in postfix notation.

Given symbols p, q, r, and s for propositions. Draw the binary tree representation of the logical expression ((p || r) && ! p ) || s) && (q || r). Write the logical express

Write down all the three object-oriented programming

Write down all the three object-oriented programming principles. Write down any two the control statements. Give brief description about Boolean data type with one example.

Create an array that stores in integers from the keyboard

create an array that stores in integers from the keyboard and then I can scan that array to check numbers in order, if the number I check is greater than the previous then I w

Write a program to compute sinx

Write a program to compute sinx for given x. The user should supply x and a positive integer n. We compute the sine of x using the series and the computation should use all

Create a java program to calculate the circumference

Create a Java program based on the geometric shapes. The program should begin by prompting you for the shape you want to calculate the circumference.

Implement the shortest job first scheduling algorithms

COSC 3406 (Programming: Java or C++) Assignment. Implement the following scheduling algorithms and report the average waiting time for all these cases. First Come First Serve

Reviews

Write a Review

 
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd