code:Its a rough currency converter from CA to US dollars, it prompts the user for an exchange rate and then prints out the US dollar based on intervals of ten.import javax.swing.JOptionPane;
public class CanadianToUSCurrencyConverterApp
{
/**
*
* @param args
*/
public static void main(String[] args)
{
//variables
int max = 110;
int interval = 10;
double usDoll;
double caDoll;
String response;
//code
response = JOptionPane.showInputDialog("Exchange Rate of 1 Can$ in US$");
double exchangeRate = Double.parseDouble(response);
for ( int count = 10; count < max; count = count + interval )
{
//for loop
usDoll = count * exchangeRate;
caDoll = count;
//output to console
System.out.println( caDoll + "$Can = " + usDoll + "$US");
}
}
}
quote:Ok, I'll agree on the style; they call it the One True Brace Style for a reason. But OO? Dude, it's a twenty-line, one-off problem. Just what benefit are you going to get from making a CurrencyInterfaceManagerFactory object? Object-oriented is for complex problems that require maintenance. Keep It Simple When Possible, eh?
Originally posted by Xavier:
I think your style could use a lot of work, and it's not taking advantage of Object Orientation in any way, but I wouldn't expect that stuff from your first program.