It 210 Final: Currency Conversion

Only available on StudyMode
  • Download(s) : 357
  • Published : September 12, 2010
Open Document
Text Preview
~Application-Level Requirements List~
1.Menu-Driven Program
2.User has option to select 1 of 5 international currency types. (Canadian dollars, Mexican pesos, English pounds, Japanese yen, and French francs) 3.Program converts foreign currency to U.S. dollars if values provided are valid. 4.Program displays the equivalent dollar amount.

5.Program returns to main menu, user has option to enter another conversion or quit the program.

~Input-Process-Output Chart~
InputProcessOutput

Menu Options: User selects 1 of 6
Display MenuCurrency Type (Integer) 1 - 5

International Value (Real) 0 - 1,000,000
Get Foreign ValueInt_Value (Real) 0 - 1,000,000

Currency Type (Integer) 1 - 5

International Value (Real) 0 - 1,000,000
Convert CurrencyUS_Value (Real) > 0

Currency Type (Integer) 1 - 5

International Value (Real) 0 - 1,000,000

US_Value (Real) > 0
Display ResultsCurrency Type (Integer) 1 - 5

Int_Value (Real) 0 - 1,000,000

US_Value (Real) > 0

~Hierarchy Chart~

~Control Flow Diagram—Main Control~

~Control Flow Diagram—Display Menu~

~Control Flow Diagram—Get Foreign Value~

~Control Flow Diagram—Convert Currency~

~Control Flow Diagram—Display Results~


~Pseudocode~

Main Control

Declare Nation As String
Write "Welcome to the Currency Conversion Program"
Write
Write "This program coverts foreign currency to US dollars." Repeat
Call Display Menu
If Selection = 1 Then
Set Nation = Canadian
End If
If Selection = 2 Then
Set Nation = Mexican
End If
If Selection = 3 Then
Set Nation = English
End If
If Selection = 4 Then
Set Nation = Japanese
End If
If Selection = 5 Then
Set Nation = French
End If
Until Selection = 0
If Selection = 0 Then
Write "Thank you for using the Currency Conversion Program"
End Program
End If
Call Get Foreign Value
Call Convert Currency
Call Display Results

End Main Control

Display Menu

Declare Selection As Integer
Repeat
Write "Select Foreign Currency"
Write ""
Write "0 - Quit The Program"
Write "1 - Canadian Dollars"
Write "2 - Mexican Pesos"
Write "3 - English Pounds"
Write "4 - Japanese Yen"
Write "5 - French Francs"
Input Selection
If Selection = 0 Then
Repeat
Write "Are you sure you want to quit program? (Y or N)"
Input Response
If Response = N Then
Call Display Menu
If Response = Y Then
Set Selection = 0
Until Response = N or Response = Y
Else If Selection < 0 Or Selection > 5
Write "Error 4: Invalid Menu Selection"
End If
Until (Selection = Int(Selection)) And (Selection > = 0) And (Selection < = 5)

End Display Menu

Get Foreign Value

Declare Int_Value As Real
Repeat
Write "Enter Foreign Value"
Write "Value Must Be A Positive Number"
Input Int_Value
If Int_Value < = 0 Or > 1,000,000 Then
Write "Error 1: Invalid Input"
Write "Value Must Be A Positive Number"
Else If Int_Value < > Real
Write "Error 2: Illegal Value
Write "Value Must Be A Number"
End If
Until Int_Value > 0 And < 1,000,000

End Get Foreign Value
Convert Currency

Declare US_Value, Rate As Real
Select Case Of Nation
Case Canadian:
Set Rate = 1.4680
Case Mexican:
Set Rate = 9.5085
Case English:
Set Rate = 0.6085
Case Japanese:
Set Rate = 104.9200
Case French:
Set Rate = 6.2561
Default:
Set Rate = 0.0
End Case
Set US_Value = Rate * Int_Vale

End Convert Currency

Display Results

Declare Currency As String
Select Case Of Nation
Case Canadian:
Set Currency = Dollars
Case Mexican:
Set Currency = Pesos
Case English:
Set Currency = Pounds
Case Japanese:
Set Currency = Yen
Case French:
Set Currency = Francs
Default:
Set Currency = " "
End Case
If Currency < > " " Then
Write "The conversion for $ ", Int_Value, " ", Nation, " ", Currency
Write "is $ ", US_Value, "US Dollars."
Else
Write "Error 5:...
tracking img