Difference between revisions of "Currency Converter"

From CompSciWiki
Jump to: navigation, search
Line 4: Line 4:
 
This program will convert dollar amounts from Canadian to US dollars, and vice versa. There will be three input dialog boxes, implemented using JOptionPane.showInputDialog. The first input will ask the user for the currency to which they would like to convert, either CAD or USD. The next input asks for the current conversion rate to the desired currency, and the final input asks for the dollar amount to be converted. The program will then display a dialog box with the dollar amounts in both the original currency and the converted amount in the new currency.
 
This program will convert dollar amounts from Canadian to US dollars, and vice versa. There will be three input dialog boxes, implemented using JOptionPane.showInputDialog. The first input will ask the user for the currency to which they would like to convert, either CAD or USD. The next input asks for the current conversion rate to the desired currency, and the final input asks for the dollar amount to be converted. The program will then display a dialog box with the dollar amounts in both the original currency and the converted amount in the new currency.
 
<br><br>
 
<br><br>
This program will require nesting of if statements and loops within one another, and there should be some input checking to ensure that inputs are valid and that all dollar amounts are greater than or equal to zero. Use a boolean variable called done to check whether the value of the first input is null. If the user clicks cancel, the program will then exit.
+
This program will require nesting of if statements and loops within one another as well as string comparision, and there should be some input checking to ensure that inputs are valid and that all dollar amounts are greater than or equal to zero. Use a boolean variable called done to check whether the value of the first input is null. If the user clicks cancel, the program will then exit.
  
  

Revision as of 02:26, 6 April 2010

Back to the Program-A-Day homepage

Problem

This program will convert dollar amounts from Canadian to US dollars, and vice versa. There will be three input dialog boxes, implemented using JOptionPane.showInputDialog. The first input will ask the user for the currency to which they would like to convert, either CAD or USD. The next input asks for the current conversion rate to the desired currency, and the final input asks for the dollar amount to be converted. The program will then display a dialog box with the dollar amounts in both the original currency and the converted amount in the new currency.

This program will require nesting of if statements and loops within one another as well as string comparision, and there should be some input checking to ensure that inputs are valid and that all dollar amounts are greater than or equal to zero. Use a boolean variable called done to check whether the value of the first input is null. If the user clicks cancel, the program will then exit.

 

SideSectionTitle

float
Taken from http://www.flickr.com/photos/daniello/565304023/

An image or By Students section

Solution

Code

Solution Code

Back to the Program-A-Day homepage