public static void main(String [] args)
{
displayHeader();
Scanner in = new Scanner(System.in);
double sum, price;
int count = 0;
sum = 0.0;
System.out.println("Enter the price of gas or -99 to Quit: ");
price = in.nextDouble();
while (price != -99)
{
price = in.nextDouble();
if (price != -99)
{
sum += price;
count++;
}
}
sum /= count;
System.out.println("\nThe average price per gallon of regular gas is " + sum);
}
So I was wondering at what point I'm losing my decimals. I've tried changing things up but I'm at a loss. Thank you in advance to anyone who lends me a hand.
Edited by Alexander, 22 November 2010 - 10:45 PM.
[code]in here[/code]


Sign In
Create Account


Back to top









