Currency Converter Program 1
Requirements
Problem: Currency Conversion
Description: The Currency Conversion application is a menu-driven program that allows
users to select one of five international currency types, input the amount of a foreign
currency, and then converts the foreign currency to dollars. The program displays the
equivalent dollar amount and returns the user to the menu until he or she enters another
conversion or quits the program.
International currency type (menu selection)
Canadian dollars (rate: 1 U.S. dollar = 1.4680 Canadian dollars)
Mexican pesos (rate: 1 U.S. dollar = 9.5085 pesos)
English pounds (rate: 1.6433 U.S. dollars = 1 pound)
Japanese yen (rate: 1 U.S. dollar = 104.9200 yen)
French francs (rate: 1 U.S. dollar = 6.2561 francs)
Application-Level Requirements List
1. The program shall present a series of user screens that prompts the user for specified
input.
2. The main user screen shall have an application title.
3. The main user screen shall have a short description telling the user how to use the
program.
4. The calculation of the currency shall be executed only after all the valid input values
are provided.
5. The program shall allow the user to clear all input fields and recompiles the
calculation.
Currency Converter Program 2
Input-Process-Output Chart
Input Process Output
Name: Display Menu Name: Currency Type
Type: Type: Integer
Range: Range: 1-6
Name: International Value Get Foreign Value Name: International Value
Type: Real Type: Real
Range: 0-1,000,000 Range: 0-1,000,000
Name: International Value Convert Currency Name: US Value
Type: Real Type: Real
Range: 0-1,000,000 Range: > 0
Name: Currency Type
Type: Integer
Range: 1-6
Name: Currency Type Display Results Name: Currency Type
Type: Integer Type: Integer
Range: 1-6 Range: 1-6
Name: International Value Name: International Value
Type: Real Type: Real
Range: 0-1,000,000 Range: 0-1,000,000
Name: US Value Name: US Value
Type: Real Type: Real
Range: > 0 Range: > 0
Currency Converter Program 3
Design
Hierarchy Chart
Currency
Conversion
Display_Menu Get_Int_Value Convert_Currency Display_Results
Flowcharts
Control Flow Diagram—-Main Control
Begin
Display_Menu
Provide exit Yes Quit?
message
No
End
Get Int Value
Convert
Concurrency
Display
Results
Currency Converter Program 4
Control Flow Diagram—Display Menu
Begin
List menu
items
Get Selection
Error 4: Invalid Valid
No
menu selection selection?
Yes
Quit? Yes Verify Quit
No
Yes
Verify Quit No
Continue with Verified?
conversion
Conversion No
Verified?
Yes
Yes
End
Currency Converter Program 5
Control Flow Diagram—Get_Int_Value
Begin
Prompt for
input
Get input
Error 2: Illegal Legal
No
value input?
Yes
Valid Error 1: Invalid
No
Input? Input
Yes
End
Currency Converter Program 6
Control Flow Diagram—Convert Currency
Begin
Canadian
Yes Rate = Canadian Rate
?
No
Mexican
Yes Rate = Mexican Rate
?
No
English
Yes Rate = English Rate
?
No
Japanese
Yes Rate = Japanese Rate
?
No
French
Yes Rate = French Rate
?
No
Rate = 0.0
US Value =
Rate*Int_Value
End
Currency Converter Program 7
Control Flow Diagram—Display Results
Begin
Canadian Nation = Canadian
Yes
? Currency = Dollars
No
Mexican Nation = Mexican
Yes
? Currency = Pesos
No
English Nation = English
Yes
? Currency = Pounds
No
Japanese Nation = Japanese
Yes
? Currency = Yen
No
French Nation = French
Yes
? Currency = Francs
No
Nation = null
Currency = null
Error 5: Invalid Currency
Yes
Currency Type = null?
No
print Nation, Int_Value,
Currency, US Value
No
End
Currency Converter Program 8
Psuedocode
Main Module
Declare selection as integer
Declare currency Type as Integer
Declare international Value as real
Declare US Value as real
Do while user wants to continue
Display Menu
Get International Value
Convert Currency
Display Results
End loop
Print exit message
End Main Module
Display Menu
Declare continue as Boolean
Set continue = true
While continue = true
Display "Welcome to the international currency conversion program"
Display "Please make a selection"
Display "International Currency Types:"
Display "1: Canadian Dollars"
Display "2: Mexican Pesos"
Display "3: English Pounds"
Display "4: Japanese Yen"
Display "5: French Francs"
Display "6: Quit"
Display "Enter a selection:";
Input currency Type
If currency Type >= 1 AND currency Type <= 5 then
Set continue = false
else if currency Type = 6
Display “Quitting Currency Conversion”
continue = false
else Display “"Error 1: Invalid menu selection."
continue = true
end if
Currency Converter Program 9
end While
End Display Menu
Get International Value
Declare value as integer
Declare continue as Boolean
Set continue = true
While continue = true
Display "Enter a currency value (positive number): "
Input international Value
if international Value > 0 AND international Value <= 1000000 then
continue = false
else
Display “"Error 2: Invalid input--Negative Number"
continue = true
end if
end while
End Get International Value
Convert Currency
Declare rate as real
Select Case of currency Type
case 1:
Set rate = 1.4680
case 2:
Set rate = 9.5085
case 3:
Set rate = .6433
case 4:
Set rate = 104.9200
case 5:
Set rate = 6.2561
default:
Set rate = 0.0
End Case
US Value = rate * international Value
End Convert Currency
Display Results
Declare nation as string
Declare currency as string
Select Case of currency Type
case CANADIAN:
nation = "Canadian";
Currency Converter Program 10
currency = "Dollars";
case MEXICAN:
nation = "Mexican";
currency = "Pesos";
case ENGLISH:
nation = "English";
currency = "Pounds";
case JAPANESE:
nation = "Japanese";
currency = "Yen";
case FRENCH:
nation = "French";
currency = "Francs";
default:
nation = "No country";
currency = "";
End Case
if currency <> “” then
Display “The value of “, international Value, “ “ , nation, “ “, currency, “ is “,
US Value, “ dollars”
else
Display "Error3: Invalid currency type."
end if
End Display Results
Test Values
Input Expected Output Comments
International Value case 1 = Error Message input out of valid range
0.0
International Value case 1 = Error Message input out of valid range
1000001
International Value case 1 = Canadian Dollars = 0.01 lower limit of International
0.01 US Dollars = 0.01468 Value case 1
International Value case 1 = Canadian Dollars = 1000.00 middle of International Value
1000.00 US Dollars = 1468.00 case 1
International Value case 1= Canadian Dollars = 7000.00 upper limit International Value
7000.00 US Dollars = 10276.00 case 1
International Value case 2= Error Message input out of valid range case 2
0.0
International Value case 2 = Error Message input out of valid range case 2
1000001
International Value case 2 = Pesos = 0.01 lower limit of International
0.01 US Dollars = 09.5085 Value case 2
International Value case 2 = Pesos = 1000.00 middle of International Value
1000.00 US Dollars = 9508.5 case 2
International Value case 2= Pesos = 7000.00 upper limit International Value
Currency Converter Program 11
7000.00 US Dollars = 66559.5 case 2
International Value case 3 = Error Message input out of valid range case 3
0.0
International Value case 3 = Error Message input out of valid range case 3
1000001
International Value case 3 = Pounds = 0.01 lower limit of International
0.01 US Dollars = 0.006433 Value case 3
International Value case 3 = Pounds = 1000.00 middle of International Value
1000.00 US Dollars = 643.3 case 3
International Value case 3= Pounds = 7000.00 upper limit International Value
7000.00 US Dollars = 4503.1 case 3
International Value case 4 = Error Message input out of valid range case 4
0.0
International Value case 4 = Error Message input out of valid range case 4
1000001
International Value case 4 = Yen = 0.01 lower limit of International
0.01 US Dollars = 1.0492 Value case 4
International Value case 4 = Yen = 1000.00 middle of International Value
1000.00 US Dollars = 104920.00 case 4
International Value case 4= Yen = 7000.00 upper limit International Value
7000.00 US Dollars = 734440.00 case 4
International Value case 5 = Error Message input out of valid range case 5
0.0
International Value case 5 = Error Message input out of valid range case 5
1000001
International Value case 5 = Francs = 0.01 lower limit of International
0.01 US Dollars = .062561 Value case 5
International Value case 5 = Francs = 1000.00 middle of International Value
1000.00 US Dollars = 6256.1 case 5
International Value case 5= Francs = 7000.00 upper limit International Value
7000.00 US Dollars = 43792.7 case 5
Currency Converter Program 12
References
Venit, S. (2004). Extended prelude to programming: Concepts and design (2nd ed.).
Boston: Scott/Jones.