Java Help Please

goudaman40

<font color=FF33FF>The TF's say 'Hello'<br><font c
Joined
Jul 13, 2003
Messages
753
I need major help with a program I am working on - I can get my Convertor.java to compile w/o a problem -

The problem comes when I do my ConvertorTest.java - I am attaching both programs -

Hello all, I had to write a program to convert from fahr to cent; gallons to liters; and dollars to euros.

I got my converter.java to compile without a problem; here is a copy of the program:

public class Convertor
{
public Convertor(int aFahr, int aGal, int aDollar)
{
int tempf = aFahr;
int gallons = aGal;
int dollars = aDollar;
}
public double convertFahrToCent(int tempf)
{
tempf = tempf - 32;

return tempf;
}
public double convertGalToLiter(int gallons)
{
Liter = (gallons * 3.7854118);

return Liter;
}
public double convertDollarToEuro(int dollars)
{
Euro = (dollars * 0.8135);

return Euro;
}

private double tempf;
private double Liter;
private double Euro;


Now here is my problem program - convertortest.java

What am I doing wrong????

javax.swing.JOptionPane;

public class ConvertorTest
{
public static void main(String[] args)
{
final double Fahr_To_Cent = 5.0 / 9.0;
final double Gallons_To_Liters = 3.7854118;
final double Dollars_To_Euros = 0.8135;

String input1 = JOptionPane.showInputDialog(
"Please enter the Fahrenheit degree:");
int tempf = Integer.parseInt(input1);

String input2 = JOptionPane.showInputDialog(
"Please enter the number of Gallons:");
int gallons = Integer.parseInt(input2);

String input3 = JOptionPane.showInputDialog(
"Please enter the amount of Dollars:");
int dollars = Integer.parseInt(input3);

Convertor FahrToCent = new Convertor(tempf);
Convertor gallonsToLiters = new Convertor(gallons);
Convertor dollarsToEuros = new Convertor(dollars);

System.out.println("Fahrenheit to Centrigrade: " * Fahr_To_Cent.Convertor(tempf));
System.out.println("Gallons to Liters: " * Gallons_To_Liters.Convertor(Liters * gallons));
System.out.println("Dollars to Euros: " * Dollars_To_Euros.Convertor(Euros * dollars));

System.exit(0);
}
}
 
Please - Please - Please - can anyone help me???:sad: :sad: :sad:
 
I think you need to define constructors for your Convertor class, one constructor for each variable type it accepts as input.

(the current code says Convertor should be called with all three variables, aFahr, aGal, aDollar)
 


Disney Vacation Planning. Free. Done for You.
Our Authorized Disney Vacation Planners are here to provide personalized, expert advice, answer every question, and uncover the best discounts. Let Dreams Unlimited Travel take care of all the details, so you can sit back, relax, and enjoy a stress-free vacation.
Start Your Disney Vacation
Disney EarMarked Producer






DIS Facebook DIS youtube DIS Instagram DIS Pinterest DIS Tiktok DIS Twitter

Add as a preferred source on Google

Back
Top Bottom