I am doing a program that will convert euros and yens to US dollars and then give the total amount of money upon exiting the program. I need a gift class to hold the total. Basically I did two file a ConvertCurrency file and a gift file. It is has been pretty much down hill from there. Any suggestion how to link the files correctly.
import java.util.*;
public class ConvertCurrency
{
public static void main (String [] args) //start main method
// define constants
final double USdollars_Rate = 1.0
final double Euro_Rate = 1.24
final double Yen_Rate = .0091
// define variables
int choice = 0;
double value = 0;
double answer = 0;
// description of Program to user
System.out.print ("This program will convert USdollars, Euros, ad Yen");
System.out.println ("to Usdollars based on the selction of the user.");
System.out.println ("Please make you selection.");
// set up input scanner
scanner stdin1 = new scanner (System.in);
// get choice from user
System.out.print ("To convert USdollars to US dollars, press 1");
System.out.println ("To convert Euros to USdollars, press 2");
System.out.println ("To convert Yen to USdollars, press 3");
System.out.println ("To exit the program, press 4");
System.out.println ( );
choice = stdin1.nextInt();
Gift choice = new Gift ();
while (choice != 4) // set up the while statement
{
switch ( choice ) // use a switch statement to switch choice
{
case 1: // USdollars conversion
choice.enterUSdollars;
break;
case 2: // Euros conversion
choice.enterEuros;
break;
case 3: // Yen conversion
choice.enterYen;
break;
default: // Exit to accumulate total
System.out.println ("Exit the program and give total.");
}
}
}
gift file
import java.util.*;
public class Gift () {
{
// method to enter USdollars
System.out.println ("Enter amount of US dollars received: ");
value = stdin1.nextDouble() ; // read in the user input
answer = value * USdollars_RATE ; // do the math
totalCollected += USD;
System.out.println(USD + "US dollars equals " + USD + "US");
//method to enter Euros
System.out.println ("Enter amount of Euros received: ");
value = stdin1.nextDouble() ; // read in the user input
answer = value * Euros_RATE;
totalCollected += USD;
System.out.println(USD + "US dollars equals " + USD + "US");
// method to enter Yen
System.out.println ("Enter amount of Yen received: ");
value = stdin1.nextDouble() ; // read in the user input
answer = value * Yen_RATE;
totalCollected += USD;
System.out.println(USD + "US dollars equals " + USD + "US");
// default method
System.out.println ("totalCollected" = USD ") ;
}
}
}
}