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 ([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<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 ([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<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 ([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;
}

Reference no: EM131018072

Questions Cloud

Write an equation for jason production possibility frontier : Given the above information, write an equation for Jason's production possibility frontier in slope intercept form where jam (J) is measured on the vertical axis and butter (B) is measured on the horizontal axis
Transistors that realize the current sources : For the folded-cascode differential amplifier of Fig. 9.38, find the value of VBIAS that results in the largest possible positive output swing, while keeping Q3: Q4: and the pnp transistors that realize the current sources out of saturation.
What is the equation for this new line : Suppose you are given the following equation: X = 2Y - 4. where X is the variable measured on the horizontal axis and Y is the variable measured on the vertical axis. Suppose that something happens so that for every X value in the original equation..
Create an analysis report : The details of open, axial, and selective coding data analysis procedures related to interview question responses.Direct quotes and in-text reference support for all factual statements.
Write an enhanced for loop that iterates over each student : 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
Bipolar differential amplifier : A bipolar differential amplifier having a simple pnp current-mirror load is found to have an input offset voltage of 2 mV. If the offset is attributable entirely to the finite β of the pnp transistors, what must βP be?
How did this week''s definition of leadership resonate : How could the poor leaders you have worked with in the past (or present) have done a better job?
Open-circuit differential gain : A current-mirror-loaded NMOS differential amplifier is fabricated in a technology for which |V1A |= 5 V/μm. All the transistors have L =0.5 μm. If the differential-pair transistors are operated at VOV = 0.25 V, what open-circuit differential gain..
Large-signal analysis and compare results : Use small-signal analysis to find the input voltage that would restore current balance to the differential pair. Repeat using large-signal analysis and compare results.

Reviews

Write a Review

JAVA Programming Questions & Answers

  How to add a static data member

Create one project for each problem; add comments to your code -  write a program which Add a static data member to count the number of objects will be created.

  Write java program to reverse contents of original array

Write down the Java program method named reversal which returns the new array which is a reversal of original array. Use [5.0, 4.4, 1.9, 2.9, 3.4, 3.5] to test method.

  Constructor that initializes the three automatic properties

Create a class called Date that adds three pieces of information as automatic properties-a   month (type int), a day (type int) and a year (type int).

  Explore how to throw and rethrow and exception

We will explore how to throw and rethrow and exception, and how to handle events in a program.  Please respond to all of the following prompts:Discuss whether it is it possible

  Question hierarchy of section

Add a class AnyCorrectChoiceQuestion to the question hierarchy of Section 9.1 that allows multiple correct choices. The respondent should provide any one of the cor- rect choices. The answer string should contain all of the correct choices, separa..

  Create a class for services offered by a hair-styling salon

Create a class for services offered by a hair-styling salon. Data fields include a String to hold the service description and write an application named Salon Report that contains an array to hold six Service objects and fill it with the data

  Identify all of the lines of code within the program

Identify all of the lines of code within the program that are associated with obtaining user input. This can be done by either copying the lines into your answers or highlighting the lines within the code.

  Write down several reasons why exception-handling

question 1 give several reasons why exception-handling techniques should not be used for conventional program

  Create a method to calculate the value of the inventory

Create another method to sort the array items by the name of the product.

  Initializing static fields

Why do static ?elds of a class have to be initialized when the class is loaded? Why can't we initialize static ?elds when the program starts? Give an example of what goes wrong if, instead of static ?elds being initialized too early, they are init..

  Ticketmaster

TICKETMASTER - this class will have: a service charge = $8.00 per ticket, tax = .085 current amount of all tickets sold. Its responsibilities are printing a list of events for sale, looking up an event for a customer, and selling a ticket to the e..

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