Chapter 1 Homework

Chapter 1 Homework - 68723 and then makes a stop and fill...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
COSC1415/COSC1436 Homework – Chapter 1 Page 1 of 1 Name Chintu Patel 8001 Homework Date Due: January 23 at 12:20pm Write an algorithm for the following problem: A salesperson leaves his home every Monday and returns every Friday. He travels by company car. Each day on the road, the salesperson records the amount of gasoline put in the car. Given the starting odometer reading (let's say 68723) before he leaves on Monday and the ending odometer reading (let's say 71289) after he returns home on Friday, design an algorithm to find the average miles per gallon. The following might be the number of gallons of gas put in the car each day: 15.75 16.30 10.95 20.65 30.00 Answer: 15.75 + 16.30 + 10.95 + 20.65 + 30.00 = 93.65 71289 – 68723 = 2566 2566 / 93.65 = 27.40 -The salesperson leaves his home every Monday and returns back every Friday. -On Monday before the salesperson leaves his home, his car’s odometer gives a reading
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 68723 and then makes a stop and fill his car up with 15.75 gallons of gas. -On Tuesday he puts 16.30 gallons of gas in his car. -On Wednesday he puts 10.95 gallons of gas in his car. -On Thursday he puts 20.65 gallons of gas in his car. -On Friday he puts 30.00 gallons of gas in his char, and when he gets home his cars odometer reads 71289. -Subtract Fridays odometer reading with Mondays odometer reading: (71289 68723 = 2566) 2566 is the total distance he has traveled between Monday through Friday. -Add up the number of gallons of gas put in his car each five days: (15.75 + 16.30 + 10.95 + 20.65 + 30.00 = 93.65) 93.65 is the total number of gallons he had put in his car. -Divide the total distance he traveled in one week by total gallons of gas put in his car: (2566 / 93.65 = 27.399) His car gives out of an average of 27.40 miles per gallon....
View Full Document

Ask a homework question - tutors are online