Program Planning Document
Your name: Steve
Date: 9/28/2011
Purpose of the Program:
he purpose of this program is to calculate gas mileage and cost per mile.
Outputs:
Cost per mile
Miles Per Gallon
Inputs:
Price of Gas
Beginning mileage
End Mileage
Gallons used
Algorithm:
Miles per gallon = (end Mileage-BeginningMileage)/gallons
Cost Per mile =cost per gallon / miles per gallon
est Plan:
Test: 100 miles/10 gallons (test case)
Expected Outcome: 10 miles per gallon
Test Cost 4 price /10
Expected Outcome .4
Actual Outcome: 10, .4
Notes:
Code (paste your code below):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Assignment1
{
/*Assignment 1
* steve Conger
* 9/28/2011 */
class Program
{
static void Main(string[] args)
{
//declare variables
double beginningMileage, endMileage, gallons, pricePerGallon,
milesPerGallon, costPerMile;
//Getting input
Console.WriteLine("Enter the beginning mileage");
beginningMileage = double.Parse(Console.ReadLine());
Console.WriteLine("Enter the ending mileage");
endMileage = double.Parse(Console.ReadLine());
Console.WriteLine("Enter the number of gallons");
gallons = double.Parse(Console.ReadLine());
Console.WriteLine("Enter the price per gallon");
pricePerGallon = double.Parse(Console.ReadLine());
//calculations
milesPerGallon = (endMileage - beginningMileage) / gallons;
costPerMile = pricePerGallon / milesPerGallon;
//Output
Console.WriteLine("Your miles per gallon are {0}", milesPerGallon);
Console.WriteLine("Your cost per mile is {0:C}", costPerMile);
Console.ReadKey();
}
}
}
No comments:
Post a Comment