Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 17

Currency Conversion

Isaac D. Samaniego

IT 210

Mr. Mohamed Meky


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)

Menu
Convert United States Convert specified foreign
currency to specified currency to United States
foreign currency currency

Application-Level Requirements List

1. The program will present a series of user screens that prompts the user for specified

input.

2. The main user screen will have an application title.

3. The main user screen should have a short description saying how to use the program.

4. The calculation should be executed only after all the valid input values are provided.

5. The program will allow the user to clear all the input fields and do the calculations over.

Input-Process-Output Chart

Input Process Output


Currency Amount Get user input Currency Amount
Currency Type Currency Type
Rate Rate
Currency Type Enter Foreign Currency Type
Currency
Currency Amount Enter Dollar Dollar Amount
Amount
Foreign Value Convert U.S. Value
Currency
Currency Amount Display Results Conversion/Equivalent Dollar
Currency Type Amount
Rate

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
Control Flow Diagram—Display Menu

Begin

List menu
items

Get Selection

Error 4: Invalid Valid


No
menu selection selection?

Yes

Quit? Yes Verify Quit

Yes

Verify Quit No
Continue with Verified?
conversion

Conversion No
Verified?

Yes
Yes

End
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
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
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
Psuedocode

Main Module
Declare Nationality as string
Declare CurrencyType as integer
Declare CurrencyAmount as real
Declare USDollar as real
Declare QuitProg as string
Call Input Module
Call Check Module
Call Currency Type Module
Call Canadian Module
Call Mexican Module
Call English Module
Call Japanese Module
Call French Module
Call Exit Module
Call Output Module

Input Module
Decleare CurrencyType as integer

Display “Welcome to Currency Converter”


Display “Please select a type of currency (Enter 1 – 6)”
Display “1 Canadian Dollars”
Display “2 Mexican Pesos”
Display “3 English Pounds”
Display “4 Japanese Yen”
Display “5 French Francs”
Display “6 Quit”
Input CurrencyType
Call Check Module
End Input Module
Check Module
Declare CurrencyType as integer

If CurrencyType < 1 or CurrencyType > 6


Then Display “Invalid currency selection. Please try again”
Call Input Module
Else
Call Currency Type Module
End Check Module

Currency Type Module


Declare CurrencyType as integer
If CurrencyType = 1
Then Call Canadian Module
Else
If CurrencyType = 2
Then Call Mexican Module
Else
If CurrencyType = 3
Then Call English Module
Else
If CurrencyType = 4
Then Call Japanese Module
Else
If CurrencyType = 5
Then Call French Module
Else
If CurrencyType = 6
Then Call Exit Module
End Currency Type Module

Canadian Module
Declare CurrencyAmount as real
Declare USDollar as real
Nationality = “Canadian Dollars”

Display, “Please Enter Amount of Currency (0-100,000)”


Input CurrencyAmount
If CurrencyAmount < 0 or CurrencyAmount > 100,000
Then Display “Invalid Amount”
Call Canadian Module
Else
USDollar = CurrencyAmount * 1.4680
Call Output Module
End Canadian Module
Mexican Module
Declare CurrencyAmount as real
Declare USDollar as real
Nationality = “Mexican Pesos”

Display, “Please Enter Amount of Currency (0-100,000)”


Input CurrencyAmount
If CurrencyAmount < 0 or CurrencyAmount > 100,000
Then Display “Invalid Amount”
Call Canadian Module
Else
USDollar = CurrencyAmount * 9.5085
Call Output Module
End Mexican Module

English Module
Declare CurrencyAmount as real
Declare USDollar as real
Nationality = “English Pounds”

Display, “Please Enter Amount of Currency (0-100,000)”


Input CurrencyAmount
If CurrencyAmount < 0 or CurrencyAmount > 100,000
Then Display “Invalid Amount”
Call Canadian Module
Else
USDollar = CurrencyAmount * .8085
Call Output Module
End English Module

Japanese Module
Declare CurrencyAmount as real
Declare USDollar as real
Nationality = “Japanese Yen”

Display, “Please Enter Amount of Currency (0-100,000)”


Input CurrencyAmount
If CurrencyAmount < 0 or CurrencyAmount > 100,000
Then Display “Invalid Amount”
Call Canadian Module
Else
USDollar = CurrencyAmount * 104.9200
Call Output Module
End Japanese Module
French Module
Declare CurrencyAmount as real
Declare USDollar as real
Nationality = “French francs”

Display, “Please Enter Amount of Currency (0-100,000)”


Input CurrencyAmount
If CurrencyAmount < 0 or CurrencyAmount > 100,000
Then Display “Invalid Amount”
Call Canadian Module
Else
USDollar = CurrencyAmount * 6.2561
Call Output Module
End French Module

Exit Module
Declare QuitProg as string

Display “Are you sure you want to Quit? Y/N”


Input QuitProg
If QuitProg = “Y” or “y”
Then Call Input Module
Else
If QuitProg = “N” or “n”
Then End
Else
Display “Invalid entry, please try again”
Call Exit Module
End Exit Module

Output Module

Declare CurrencyAmount as real


Declare Nationality as string
Declare USDollar as real
Display “The value of “;CurrencyAmount;” ”;Nationality;” is “;USDollar” U.S. Dollars

Display “Press any key to return to Main Menu”


Pause

Call Input Module

End Output Module


Currency Conversion Test Procedures

**********Begin Test Procedure***********

------------Menu Error Testing------------

Test Case 1:
Inputs:
CurrencyType = “U”
Expected Output:
Invalid currency selection. Please try again

Test Case 2:
Inputs:
CurrencyType = “0”
Expected Output:
Invalid currency selection. Please try again

Test Case 3:
Inputs:
CurrencyType = “9”
Expected Output:
Invalid currency selection. Please try again

------------End Menu Error Testing------------

----------Currency Conversion Testing----------

Test Case 1: Valid International Currency = Canadian


Inputs:
CurrencyType = 1
CurrencyAmount = 100.0
Expected Output:
USDollar = 68.12

Test Case 2: Valid International Currency = Mexican


Inputs:
CurrencyType = 2
CurrencyAmount = 100.0
Expected Output:
USDollar = 10.52
Test Case 3: Valid International Currency = English
Inputs:
CurrencyType = 3
CurrencyAmount = 100.0
Expected Output:
USDollar = 164.33

Test Case 4: Valid International Currency = Japanese


Inputs:
CurrencyType = 4
CurrencyAmount = 100.0
Expected Output:
USDollar = 00.95

Test Case 5: Valid International Currency = French


Inputs:
CurrencyType = 5
CurrencyAmount = 100.0
Expected Output:
USDollar = 15.98

Test Case 6: Valid International Currency = Quit


Inputs:
CurrencyType = 6
Expected Output:
End program

----------End Currency Conversion Testing----------

----------Conversion Error Testing----------

Test Case 1: Valid International Currency = Canadian


Inputs:
CurrencyType = 1
CurrencyAmount = 0
Expected Output:
Invalid Amount

Test Case 2: Valid International Currency = Mexican


Inputs:
CurrencyType = 2
CurrencyAmount = 50000000
Expected Output:
Invalid Amount
Test Case 3: Valid International Currency = English
Inputs:
CurrencyType = 2299938847
CurrencyAmount = 100.0
Expected Output:
Invalid Amount

Test Case 4: Valid International Currency = Japanese


Inputs:
CurrencyType = 9
CurrencyAmount = 0
Expected Output:
Invalid Amount

Test Case 5: Valid International Currency = French


Inputs:
CurrencyType = 99000000
CurrencyAmount = 100.0
Expected Output:
Invalid Amount

----------End Conversion Error Testing----------

----------Output Testing----------

Test Case 1: Valid International Currency = Canadian


Inputs:
CurrencyType = 1
CurrencyAmount = 100.0
Expected Output:
The value of 100 Canadian Dollars is 68.12 U.S Dollars

Test Case 2: Valid International Currency = Mexican


Inputs:
CurrencyType = 2
CurrencyAmount = 100.0
Expected Output:
The value of 100 Mexican Pesos is 10.52 U.S Dollars
Test Case 3: Valid International Currency = English
Inputs:
CurrencyType = 3
CurrencyAmount = 100.0
Expected Output:
The value of 100 English Pounds is 164.33 U.S Dollars

Test Case 4: Valid International Currency = Japanese


Inputs:
CurrencyType = 4
CurrencyAmount = 100.0
Expected Output:
The value of 100 Japanese Yen is 00.95 U.S Dollars

Test Case 5: Valid International Currency = French


Inputs:
CurrencyType = 5
CurrencyAmount = 100.0
Expected Output:
The value of 100 French Francs is 15.98 U.S Dollars

Test Case 6: Valid International Currency = Quit


Inputs:
CurrencyType = 6
Expected Output:
Are you sure you want to Quit? Y/N

----------End Output Testing----------

**********End of Test Procedure**********

You might also like