Help with my program I'm new...
I have a program to write: Wrtie a class MPG, which has two instance variables miles and gallons, three instance methods printmpg(), setmiles(float m) and setgallons (float g) and aconstructor MPG (float m, float g).
(i) printMPG() - calculate and prints the miles per gallon based on the values held in the instance variables miles and gallons - mpg=miles/gallons.
(ii)set miles (float m) - set the miles i.e set miles to the value of the parameter passed
(iii) setgallons(float g) - set the gallons i.e sets gallons to the value of the parameter passed
(iv) MPG (Float m, float g) - the constructor which sets the instance variable miles and gallons.
This is what I have and I dont know what to do after. I am completely lose. Please help someone...
Code :
import java.io;
class MPG
{
//instance variable
int miles;
int gallons;
//constructor
MPG (float m, float g)
{
miles=m; gallons=g;
}
//methods
double PrintMPG()
{
return miles/gallons;
}
I am really really lost.. Please someone help. I know this is a simple program... Thanks...
Re: Help with my program I'm new...