This pseudocode segment is intended to describe computing thecost per day and th
ID: 3608482 • Letter: T
Question
This pseudocode segment is intended to describe computing thecost per day and the cost per week for a vacation.(Find bugs and correct this pseudocode). input totalDollarsSpent input daysOnTrip costPerDay = totalMoneySpent * daysOnTrip weeks = daysOnTrip / numberOfWeeks print costPerDay, week This pseudocode segment is intended to describe computing thecost per day and the cost per week for a vacation.(Find bugs and correct this pseudocode). input totalDollarsSpent input daysOnTrip costPerDay = totalMoneySpent * daysOnTrip weeks = daysOnTrip / numberOfWeeks print costPerDay, week input totalDollarsSpent input daysOnTrip costPerDay = totalMoneySpent * daysOnTrip weeks = daysOnTrip / numberOfWeeks print costPerDay, weekExplanation / Answer
costPerDay = totalMoneySpent *daysOnTrip should be costPerDay =totalDollarsSpent / daysOnTrip. The errors here arethey've misnamed totalDollarsSpent astotalMoneySpent, and they are multiplying by thenumber of days rather than dividing like they should.They also need to change weeks = daysOnTrip /numberOfWeeks to weeks = daysOnTrip / 7.numberOfWeeks is meaningless.
We also have never calculated the cost per weeks, so we needto add a line here saying costPerWeek = totalMoneySpent /numberOfWeeks.
Finally, we need to change the last line to printcostPerDay, costPerWeek.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.