Test class:
CODE
import javax.swing.JOptionPane;
public class CurConversionTest {
public static void main(String[] args) {
String input = JOptionPane.showInputDialog(\\\"Enter the value of the Euro\\\");
double euro = Double.parseDouble(input);
CurConversion a = new CurConversion(euro);
boolean done;
done = false;
double dollar;
while (!done)
{
input = JOptionPane.showInputDialog(\\\"Enter dollar amount to convert. Cancel quits\\\");
if (input == null)
done = true;
else
{
dollar = Double.parseDouble(input);
System.out.println(\\\"$\\\" + dollar + \\\" is equal to \\\" + a.convert(dollar) + \\\" Euros.\\\");
}
}
}
}
Our teacher wants us to use multiple classes so we can get used to having a lot of methods, so here\'s the main class:
CODE
public class CurConversion
{
public CurConversion(double euro)
{
euroValue = euro;
}
public double convert(double dollar)
{
return euroValue * dollar;
}
private double euroValue;
}