warriorone357 0 Newbie Poster

This time I am trying a different way to write a program that takes user input, converts euros or yen to u.s. dollars and should output the total dollars collected when the user chooses to exit the program. Can someone give me a clue about what I am doing wrong???

import javax.swing.JOptionPane;
import java.lang.Math;


class Gifts {
double dollars;
double euros;
double yen;
double dollarsRate;
double eurosRate;
double yenRate;
double dollarInDollars;
double eurosInDollars;
double yenInDollars;


double dollarInDollars(){
return dollars * dollarsRate;
}
double eurosInDollars(){
return euros *eurosRate;
}


double yenInDollars(){
return yen * yenRate;
}
}


public class GiftsDemo {
public static void main (String[]args){
Gifts my_gift = new Gifts();
Gifts my_gift1 = new Gifts();
Gifts my_gift2 = new Gifts();
Gifts my_gift3 = new Gifts();


double dollarsinDoll;
double eurosInDoll;
double yenInDoll;
double total;


String choice ="";
while(!(choice.equalsIgnoreCase("x"))){


double totalCollected= 0.0;


String inputDollars = JOptionPane.showInputDialog("Enter dollar amount:");
String inputEuros = JOptionPane.showInputDialog("Enter Euros amount:");
String inputYen = JOptionPane.showInputDialog("Enter Yen amount:");


my_gift1.dollars = Double.parseDouble(inputDollars);
my_gift1.dollarsRate=1.00;
my_gift2.euros = Double.parseDouble(inputEuros);
my_gift1.eurosRate=1.24;
my_gift1.yen = Double.parseDouble(inputYen);
my_gift1.yenRate=0.0092;


totalCollected= Double.parseDouble(inputDollars) + my_gift2.eurosInDollar
(Double.parseDouble(inputEuros)) + my_gift3.yenInDollar(Double.parseDouble(inputYen));



dollarsInDoll = my_gift1.dollarInDollars();
System.out.println("Dollars = "+ dollarsInDoll);


eurosInDoll = my_gift2.eurosInDollars();
System.out.println("Euros= "+ eurosInDoll);


yenInDoll = my_gift3.yenInDollars();
System.out.println("Yen = "+ yenInDoll);


System.out.println("Total Collected is " + totalCollected);
}



}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.