strucquiz answer

Strucquiz answer - CS 31 Quiz 14 John A Rohr Gasoline Mileage Calculator Array of Structs This program calculates gasoline mileage using an array

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Page 1 // CS 31 Quiz 14 // February 28, 2007 // John A. Rohr // // Gasoline Mileage Calculator // Array of Structs // This program calculates gasoline mileage // using an array of structs of type double data // Inputs: Odometer readings and gallons of gas. // Output: Miles per gallon. #include <iostream> using namespace std int main() { const int INITIAL_TANKS = 5 // Initial number of purchases struct GasData// Gasoline data struct { double miles // Odometer reading double gallons // Amount of gasoline purchased double mpg // Mileage for purchase } double initialMiles // Initial mileage reading double totalGallons // Total gallons purchased double milesPerGallon // Overall mileage int tank // Tank number int capacity // Maximum number of purchases int index // Accumulate loop index bool done // Done indicator GasData*gas // Gasoline data pointer // Display a program title cout << "GASOLINE MILEAGE CALCULATOR" << endl // Display a blank line cout << endl // Allocate the initial gas data array
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/12/2009 for the course CS 31 taught by Professor Melkanoff during the Winter '00 term at UCLA.

Page1 / 8

Strucquiz answer - CS 31 Quiz 14 John A Rohr Gasoline Mileage Calculator Array of Structs This program calculates gasoline mileage using an array

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online