List the names of subroutines of the hierarchy chart, and then write complete ps
ID: 3582571 • Letter: L
Question
List the names of subroutines of the hierarchy chart, and then write complete pseudocode for the following problem. You will not have to create a data dictionary for this exercise. Problem: Students get a discount on the tuition paid. The discount is based on a student's code and the registered number of course credits. A student with a code "M" for a military job, and registered for more than four credits is eligible for 5% discount on the tuition amount. A student with a code "C" for a corporate employee, and registered for more than six credits is eligible for 4% discount on the tuition amount. Produce the pseudocode logic for an algorithm that will compute the tuition' discount for each student. The information is given as follows: - The output will consist of a screen display showing the student's name, code, and discount received. - The input will consist of the file with records containing the student's name, code, and tuition amount. - The processing will compute the discount received by each student. If the student's code is other than "M" or "C", there should be no discount on the tuition amount. Note: Your solution should contain a mainline, and at least three subroutines.
Explanation / Answer
main()
{
allRecords = readData(inputFile)
foreach (record; records)
{
discount = calculateDiscount(record)
printDiscount(record, discount)
}
}
records readData(inputFile)
{
file = read(inputFile, "r")
data = [ ]
foreach (line; file)
{
data ~= line
}
}
discount calculateDiscount(record)
{
if (record.code == "M" and record.registeredCredits > 4)
{
return 5
}
if (record.code == "C" and record.registeredCredits > 6)
{
return 4
}
else
{
return 0
}
}
void printDiscount(record, discount)
{
print record.name, record.code, record.discount
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.