Need help on this MPG program

Hi all,

The purpose of this program is listed in

// Inputs the miles driven and gallons used (both integers) for each tankful.

// Calculates and displays miles per gallon obtained for each tankful and print

// the combined miles per gallon obtained for all tankfuls up to this point.

// All results should be floating point. Use Scanner and sentinel-controlled

// repetition to obtain data from the user.

// Exercise 4.17 MPG.java

import java.util.Scanner;

public class MPG

{

private int milesDriven;

private int gallonsUsed;

private float result;

public void setMilesDriven( int miles )

{

milesDriven = miles;

}

public void setGallonsUsed( int gallons )

{

gallonsUsed = gallons;

}

public String getMilesDriven( int miles )

{

return milesDriven; // error occurs here

}

public String getGallonsUsed( int gallons )

{

return gallonsUsed;

}

public MPG( float result )

{

result = gallons * miles;

System.out.printf( result);

}

}

I try to compile this program, but the error I get is "incompatible types-found int but expected java.lang.String. How do I fix this, and how do I sentinel control? If you can help me with these two things, I'd appreciate it.

[1376 byte] By [asian_cajun_2000a] at [2007-10-2 16:59:55]
# 1

What has this got to do with algorithms?

Please post your question in a more appropriate part of the forum.

I suggest one of these:

New To Java Technology: http://forum.java.sun.com/forum.jspa?forumID=54

Java Programming: http://forum.java.sun.com/forum.jspa?forumID=31

prometheuzza at 2007-7-13 18:13:21 > top of Java-index,Other Topics,Algorithms...