Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Main. { Call PrgmHeader. Call ReportInit. Input custID. While (custID > 0) { Cal

ID: 3627497 • Letter: M

Question

Main.
{
Call PrgmHeader.
Call ReportInit.
Input custID.
While (custID > 0)
{
Call Customer.
}
Call CalcAvg.
Call ReportOut.
Stop!
}
PrgmHeader.
{
Output header information.
}

ReportOut.
{
Output totEndBal, avgEndBal, totInt.
}
Customer.
{
Call CustInit.
Call GetCustInfo.
Call CustInfoOut.
Input transNr.
While (transNr > 0)
{
Call Transaction.
}
Call CustSummary.
Call CustSumOut.
custCount = custCount + 1.
totEndBal = totEndBal + endBal.
totInt = totInt + interest.
Input custID.
}
CalcAvg.
{
avgEndBal = totEndBal / custCount.

}
Page 4
Transaction.
{
Call GetTransInfo.
Call TransInfoOut.
Call UpdateCustTots.
Input transNr.
}
ReportInit.
{
totEndBal = totInt=custCount = 0.
}
CustInit.
{
totalPurch = totalPay = 0.
}
GetCustInfo.
{
Input custName, balFrwd.
}
CustInfoOut.
{
Output custID, custName, balFrwd.
}
GetTransInfo.
{
Input type, date, amt .
}
TransInfoOut.
{
Output transNr, type, date, amt.
}
UpdateCustTots.
{
If (type = ‘D’)
{
totalPurch = totalPurch + amt.
}
else
{
If (type = ‘C’)
{
totalPay = totalPay + amt.
}
else
{
Output “Invalid type entered - transaction not processed”.
}
}
}
Page 5
CustSummary.
{
If( (balFrwd – totalPay) > 0)
{
interest = (balFrwd – totalPay) * .005.
}
else
{
interest = 0.
}
endBal = balFrwd + totalPurch – totalPay + interest.
}
CustSumOut.
{
Output totalPurch, totalPay, interest, endBal.
}

Explanation / Answer

I'm not sure what you wanted for the program header information, so that one line is unfinished. The rest of it works, though: import java.io.*; import java.text.*; public class CustomerInfo{ int custID, transNr, custCount; double totalPurch, totalPay, totEndBal, avgEndBal, balFrwd, amt, interest, endBal, totInt; String custName, type, date; DecimalFormat twoDigitsPastPoint = new DecimalFormat ("0.00"); //rounds off money amts to two places after the decimal BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); public void PrgmHeader(){ //Output header information. } public void ReportOut(){ avgEndBal = Double.parseDouble(twoDigitsPastPoint.format(avgEndBal)); totEndBal = Double.parseDouble(twoDigitsPastPoint.format(totEndBal)); totInt = Double.parseDouble(twoDigitsPastPoint.format(totInt)); System.out.println("Total End Balance: $" + totEndBal); System.out.println("Average End Balance: $" + avgEndBal); System.out.println("Total Interest: " + totInt); } public void Customer(){ CustInit(); GetCustInfo(); CustInfoOut(); System.out.println("Input Transaction Number or -1 to end."); try{ transNr = Integer.parseInt(reader.readLine()); while(transNr > 0){ Transaction(); } } catch (IOException ioe){ } CustSummary(); CustSumOut(); custCount++; totEndBal = totEndBal + endBal; totInt = totInt + interest; System.out.println("Input Customer ID"); try{ custID = Integer.parseInt(reader.readLine()); } catch (IOException ioe){ } } public void CalcAvg(){ avgEndBal = totEndBal / custCount; } public void Transaction(){ GetTransInfo(); TransInfoOut(); UpdateCustTots(); System.out.println("Input Transaction Number."); try{ transNr = Integer.parseInt(reader.readLine()); } catch (IOException ioe){ } } public void ReportInit(){ totEndBal = 0; totInt = 0; custCount = 0; } public void CustInit(){ totalPurch = 0; totalPay = 0; } public void GetCustInfo(){ System.out.println("Input Customer Name."); try{ custName = reader.readLine(); } catch (IOException ioe){ } System.out.println("Input Balance Frwd."); try{ balFrwd = Double.parseDouble(reader.readLine()); } catch (IOException ioe){ } } public void CustInfoOut(){ System.out.println("Customer ID: " + custID); System.out.println("Customer name: " + custName); System.out.println("Balance Frwd: $" + balFrwd); } public void GetTransInfo(){ System.out.println("Input Type."); try{ type = reader.readLine(); System.out.println("Input Date."); date = reader.readLine(); System.out.println("Input Amount."); amt = Double.parseDouble(reader.readLine()); } catch (IOException ioe){ } } public void TransInfoOut(){ System.out.println("Transaction Number: " + transNr); System.out.println("Type: " + type); System.out.println("Date: " + date); System.out.println("Amount: " + amt); } public void UpdateCustTots(){ if(type.equalsIgnoreCase("d")){ totalPurch = totalPurch + amt; } else if(type.equalsIgnoreCase("c")){ totalPay = totalPay + amt; } else{ System.out.println("Invalid type entered - transaction not processed."); } } public void CustSummary(){ if(( (balFrwd-totalPay) > 0)){ interest = (balFrwd-totalPay) * .005; } else{ interest = 0; } endBal = balFrwd + totalPurch-totalPay + interest; } public void CustSumOut(){ interest = Double.parseDouble(twoDigitsPastPoint.format(interest)); endBal = Double.parseDouble(twoDigitsPastPoint.format(endBal)); System.out.println("Total Purchase: " + totalPurch); System.out.println("Total Pay: " + totalPay); System.out.println("Interest: " + interest); System.out.println("Ending Balance: " + interest); } public static void main(String[] args){ CustomerInfo c = new CustomerInfo(); c.PrgmHeader(); c.ReportInit(); System.out.println("Input Customer ID or -1 to end."); try{ c.custID = Integer.parseInt(c.reader.readLine()); } catch (IOException ioe){ } while(c.custID > 0){ c.Customer(); } c.CalcAvg(); c.ReportOut(); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote