0

I am having a problem getting my calculations to work here. I managed to get the objects in place. Any suggestions??

```
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class TravelCostEstimator Applet implements ActionListener
{
//This part defines how the program will look
private Choice choice;
Label companyLabel = new Label("Traveler's Gasoline Calculator" );
Label vehicleLabel = new Label("Enter Your Type of Vehicle");
Label fuelLabel = new Label("Enter Your Type / Grade of Fuel");
Label milesLabel = new Label("Enter the Number of Miles You Will Travel");
TextField milesEntered = new TextField(9);
Button calcButton = new Button("Calculate");
Label outputLabel = new Label("Click to calculate how much your trip will cost.");
TextArea outputArea = new TextArea("Your trip costs are",5,80, TextArea.SCROLLBARS_NONE);
//This serves as the main method used by the main class
public static void main(String[] args)
{
double totalOilChangeCost, totalFuelCost, totalTravelExpense, fuelPrice;
double oilChangeCost = 30.00;
double fuelSupeUnleadedCost = 3.00;
double fuelUnleadedCost = 2.90;
double fuelLeadedCost = 2.50;
double fuelDieselCost = 4.00;
int distanceTravel, milesPerTank, tankCapacity, milesEntered;
int milesPerGallon = 15;
int oilChangeRequired = 3000;
int vehicleCompactTankCapacity = 13;
int vehicleMidSizeTankCapacity = 18;
int vehicleLuxuryTankCapacity = 15;
int vehicleSUVTankCapacity = 23;
char vehicleLabel, fuelLabel, vehicleLabelSelected, fuelLabelSelected;
//The following calls the methods
totalOilChangeCost = getTotalOilChangeCost() ;
totalFuelCost = getTotalFuelCost() ;
totalTravelExpense = getTotalTravelExpense() ;
fuelPrice = getfuelPrice () ;
distanceTravel = getDistanceTravel() ;
milesPerTank = getMilesPerTank() ;
tankCapacity = getTankCapacity() ;
totalTravelExpense = getTotalTravelExpense();
totalOilChangeCost = getTotalOilChangeCost();
}
//The following defines the methods from above
public static double getTotalOilChangeCost()
{
if(milesEntered <3000) totalOilChange = 0;
else totalOilChange = milesEntered/3000 *30;
double totalOilChangeCost = (distanceTravel/3000)*30;
totalOilChangeCost = Double.parseDouble();
return totalOilChangeCost;
}
public static double getTotalFuelCost()
{
double totalGasCost = (distanceTravel/milesPerTank)*gasPrice;
totalFuelCost = Double.parseDouble();
return totalFuelCost;
}
public static double getTotalTravelExpense()
{
double totalTravelExpense = totalFuelCost + totalOilChange;
totalTravelExpense = Double.parseDouble();
return totalTravelExpense;
}
public static double getFuelPrice ()
{
if (fuelLabel.choice == "Super Unleaded") fuelLabelSelected = 3.00;
if (fuelLabel.choice == "Unleaded") fuelLabelSelected = 2.90;
if (fuelLabel.choice == "Leaded") fuelLabelSelected = 2.50;
if (fuelLabel.choice == "Diesel") fuelLabelSelected = 4.00;
double fuelPrice = fuelLabelSelected;
}
public static int getDistanceTravel()
{
double milesEntered = Double.parseDouble(milesEntered.getText());
if (milesEntered >=0) return distanceTravel;
int distanceTravel = milesEntered;
}
public static int getMilesPerTank()
{
int milesPerTank = tankCapacity * 15;
}
public static int getTankCapacity()
{
if (vehicleLabel.choice == "Compact") vehicleLabelSelected = 13;
if (vehicleLabel.choice == "Mid-Size") vehicleLabelSelected = 18;
if (vehicleLabel.choice == "Luxury") vehicleLabelSelected = 15;
if (vehicleLabel.choice == "SUV") vehicleLabelSelected = 23;
int tankCapacity = vehicleTypeSelected;
}
//This part makes room for the input/output of the form
public void init()
{
setSize(600, 400);
setLayout(new FlowLayout(FlowLayout.LEFT, 45, 70));
setForeground(Color.black);
setFont(new Font("sansserif", Font.PLAIN, 14));
add(companyLabel);
add(vehicleLabel);
choice = new Choice();
choice.addItem("Compact");
choice.addItem("Mid-Size");
choice.addItem("Luxury");
choice.addItem("SUV");
add(choice);
add(fuelLabel);
choice = new Choice();
choice.addItem("Super Unleaded");
choice.addItem("Unleaded");
choice.addItem("Leaded");
choice.addItem("Diesel");
add(choice);
add(milesLabel);
add(milesEntered);
add(calcButton);
calcButton.addActionListener(this);
add(outputLabel);
add(outputArea);
}
public void output(double totalOilChangeCost, double totalTravelExpense)
{
DecimalFormat twoDigits = new DecimalFormat("$#,000.00");
outputArea.setText("Your total oil changes will cost " + twoDigits.format(totalOilChangeCost) + "Your entire trip will cost" + twoDigits.format(totalTravelExpense));
}
public void actionPerformed(ActionEvent buttons)
{
if (buttons.getSource() == calcButton)
{
}
}
```

*Edited 3 Years Ago by mike_2000_17*: Fixed formatting