aspose file tools*
The moose likes Beginning Java and the fly likes add totals after Gifts object keeps track of input Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "add totals after Gifts object keeps track of input" Watch "add totals after Gifts object keeps track of input" New topic
Author

add totals after Gifts object keeps track of input

Shawn Rizzo
Greenhorn

Joined: Jun 18, 2005
Posts: 9
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

Joined: Jun 18, 2005
Posts: 9
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

Joined: Feb 08, 2004
Posts: 1281
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 ]

java amateur
Shawn Rizzo
Greenhorn

Joined: Jun 18, 2005
Posts: 9
how do output it in UBB? I'm using jcreator.
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
when you post, bellow textbox, there are several UBB Code buttons: use code
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: add totals after Gifts object keeps track of input