Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

add totals after Gifts object keeps track of input

 
Shawn Rizzo
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello again! I'm attempting to add the totals of the data that is tracked by my Gifts object, here is what I have so far, any help offered would greatly appreciated.

import javax.swing.*;
import java.util.*;
import java.text.*;


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 GiftsCalculator {
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"))){
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_gift2.eurosRate = 2.00;
my_gift3.yen = Double.parseDouble(inputYen);
my_gift3.yenRate = 5.00;







} // end while loop

System.exit(0);
}

}
 
Shawn Rizzo
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I should clarify that I want it to print out the total savings once the 3 types of currency are inputted, then exit
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please UBB code to format your code

i dont quite get why do you need this:
String choice = "";
while (!(choice.equalsIgnoreCase("x"))) {

[ June 19, 2005: Message edited by: miguel lisboa ]
 
Shawn Rizzo
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do output it in UBB? I'm using jcreator.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when you post, bellow textbox, there are several UBB Code buttons: use code
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic