CreateaprogramcalledBudget.java. MyprogramwouldbeConwayBudget.javaandmyclassnamewouldbeConwayBudget....

CreateaprogramcalledBudget.java. MyprogramwouldbeConwayBudget.javaandmyclassnamewouldbeConwayBudget.Alltheinputfromtheusershouldbefromthecommandline(usetheScannerobject).YouonlyneedtocreateoneScannerobjecttohandlealltheinput.DonotuseJOptionPane.This programwill simulateenteringvaluesforamonthlybudget.Itwill totaltheuser’sexpensesforthemonth andthenindicatewhethertheuserwentoverbudget.Theprogramwillnotknowhowmanyvaluestheuserwillenter.Theuserwillenterthesentinelvalueof-1 whentheuserhascompletedenteringexpenses.Theprogramwill utilizea while loopto keeparunningtotalofexpenses.(Use awhileloop;donotuseado-whileloop.)Beforetheloopbegins,prompttheuserforthefirstexpense(thisiscalledaprimingread).Withintheloop,addtheexpensetotherunningtotal.Thenprompttheuserforthenextexpense.Theprogram willalsoneedtokeeptrackofthenumberofexpenses theuserenters.Thiscanbeaccomplishedbyusingavariablethatisincrementedby1withintheloop. Theuserwillenter thevalue-1 whentherearenomoreexpenses toenter.This sentinelvalueof-1 willterminatetheloop.Theloopconditionmust beconstructedtocheckforthesentinelvalue.Whentheloophascompleted,theprogramwillprinttothescreen thetotalbudgetedforthemonth,thenumberofexpenses,andexpensetotal,andwhethertheuserwasunder,atoroverbudget.Notes:• Usea “primingread”beforetheloopbegins.Seecodeonpage220foranexample.• Severalintvariables (forexpensetotal,expensecount) willbeneededfortheprogramtorunproperly.Initializethesevariablesto appropriate valuesbeforetheloopbegins.• Theloopshouldhandletestingthecondition.There isnoneedtotestforthesentinelusinganifstatement.• Theusercanenter-1 asthefirstvalueiftherearenoexpenses toenter.Theloopshouldnotbeenteredinthiscase.Makesuretotestforthis.• Testtheprogram!Usethevaluesshowninthesampleoutputandmakesurethesameresults are printed.

Aug 14, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here