Page 1

Control Flow Diagram—Convert Currency

Final Project: Currency Conversion Purpose of Assignment: The purpose of this assignment is to develop a program that successfully converts currency using one of 5 options.

Description: This application is an easy to use currency converter. The user will input an amount of currency and choose from one of five options to convert it. The currency will then be converted and displayed.

IT 210


Control Flow Diagram—Convert Currency

Input-Process-Output

Input

Process

Output

Amount of Currency Type of Currency Rate Type of Currency Converting

Get user input

Currency_Amount Currency_Type Rate Currency_Convert_Type

Amount of Currency Foreign Value Currency_Amount Currency_Type Rate

Enter Foreign Currency Enter Currency Amount Convert Currency Display Results

Currency_Amount US_Currency_Amount US_Currency_Amount

Hierarchy Chart

Main Module

Display Menu Module

Get Currency Module

Convert Currency Modules

Display Output Results Module

IT 210


Control Flow Diagram—Convert Currency Control Flow Diagram—Main Control

Begin

Input currency amount

Provide exit Message

Yes

Quit? No

End

Select currency to be converted

Divide by currency Rate

Display converted

results

IT 210


Control Flow Diagram—Convert Currency Control Flow Diagram—Display Menu

Begin

Input currency amount

Input currency type

Error 4: Invalid Menu selection

No

Valid Selection? Yes Quit?

Invalid selection

Yes

No Compute currency conversion

Conversion Verified? Yes

Quit Verified?

No

No

Yes

End

IT 210


Control Flow Diagram—Convert Currency Control Flow Diagram—Get_Int_Value

Begin

Currency amount

Currency type

Invalid selection

No

Legal input? Yes

Valid Input?

No

Invalid selection

Yes

End

IT 210


Control Flow Diagram—Convert Currency

Begin

Canadian ?

Yes

Rate= Canadian rate

Yes

Rate= Mexican rate

Yes

Rate= English rate

Yes

Rate=Japanese rate

No

Mexican No

English ? No

Japanese No

French

Yes

Rate = French Rate

No

Rate = 0.0

US Value = Rate*Int_Value

End

IT 210


Control Flow Diagram—Convert Currency Control Flow Diagram—Display Results Begin

Canadian

Yes

Nation = Canadian Currency = Dollars

No

Mexican

Yes

Nation= Mexican Currency=dollars

Yes

Nation=English Currency=dollars

No

English No

Japanese

Yes

Nation=Japanese Currency=dollars

No

French ?

Yes

Nation=French Currency=dollars

No

Invalid selection

Error 5: Invalid Currency Type

Yes

Currency = null? No

print Nation, Int_Value, Currency, US Value No

End

IT 210


Control Flow Diagram—Convert Currency

Pseudo Code Application-Level Requirements List 1) 2) 3) 4)

Get input from the user. Enter the amount of foreign currency that is to be converted. Select the type of foreign currency that is to be converted to U.S dollars. Divide the amount of currency by the foreign currency rate.

Canadian Dollars (Rate: 1 U.S. Dollar = 1.018 Canadian Dollars.) Mexican Pesos (Rate: 1 U.S. Dollar = 11.984 Pesos.) English Pounds (Rate: 1 U.S. Dollars = .6247Pound.) Japanese Yen (Rate: 1 U.S. Dollar = 81.4725 Yen.) French Francs (Rate: 1 U.S. Dollar = 4.6746 Francs.) 5) Output the converted results. Main Module Declare Nationality as string Declare Currency_Type as integer Declare Currency_Amount as real Declare US_Dollar as real Declare Quit_Program 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 Declare Currency_Type as integer Write, “Hello, and welcome to the greatest currency” Write, “program ever created. Enjoy your stay.” Write, “Please select the currency you want to Write, “convert using the menu located below” Write, “(Enter 1, 2, 3, 4, 5, or 6 only please)”

IT 210


Control Flow Diagram—Convert Currency

Write, “1 - Canadian Dollars” Write, “2 - Mexican Pesos” Write, “3 - English Pounds” Write, “4 - Japanese Yen” Write, “5 - French Francs” Write, “6 - Quit” Input Currency_Type Call Check Module End Input Module Check Module Declare Currency_Type as integer If Currency_Type < 1 or Currency_Type > 6 Then Write, “Hold on their buddy. What you just typed” Write, “was invalid. Please choose a number between” Write, “1 and 6 only. Let’s try that again, shall we?” Call Input Module Else Call Currency Type Module End Check Module Currency Type Module Declare Currency_Type as integer If Currency_Type = 1 Then Call Canadian Module Else If Currency_Type = 2 Then Call Mexican Module Else If Currency_Type = 3 Then Call English Module Else If Currency_Type = 4 Then Call Japanese Module Else If Currency_Type = 5 Then Call French Module Else If Currency_Type = 6 Then Call Exit Module

IT 210


Control Flow Diagram—Convert Currency

End Currency Type Module Canadian Module Declare Currency_Amount as real Declare US_Dollar as real Nationality = “Canadian Dollars” Write, “Please Enter Amount of Currency to convert: (0-100,000)” Input Currency_Amount If Currency_Amount < 0 or Currency_Amount > 100,000 Then Write “Invalid Amount, please try again.” Call Canadian Module Else US_Dollar = Currency_Amount * 1.4680 Call Output Module End Canadian Module Mexican Module Declare Currency_Amount as real Declare US_Dollar as real Nationality = “Mexican Pesos” Write, “Please Enter Amount of Currency to convert: (0-100,000)” Input Currency_Amount If Currency_Amount < = 0 or Currency_Amount > 100,000 Then Write, “Invalid Amount, please try again.” Call Canadian Module Else US_Dollar = Currency_Amount * 9.5085 Call Output Module End Mexican Module English Module Declare Currency_Amount as real Declare US_Dollar as real Nationality = “English Pounds” Write, “Please Enter Amount of Currency to convert: (0-100,000)” Input Currency_Amount If Currency_Amount < 0 or Currency_Amount > 100,000 Then Write, “Invalid Amount, please try again.” Call Canadian Module Else

IT 210


Control Flow Diagram—Convert Currency

US_Dollar = Currency_Amount * .8085 Call Output Module End English Module Japanese Module Declare Currency_Amount as real Declare US_Dollar as real Nationality = “Japanese Yen” Write, “Please Enter Amount of Currency to convert: (0-100,000)” Input Currency_Amount If Currency_Amount < 0 or Currency_Amount > 100,000 Then Write, “Invalid Amount, please try again.” Call Canadian Module Else US_Dollar = Currency_Amount * 104.9200 Call Output Module End Japanese Module French Module Declare Currency_Amount as real Declare US_Dollar as real Nationality = “French francs” Write, “Please Enter Amount of Currency to convert: (0-100,000)” Input Currency_Amount If Currency_Amount < 0 or Currency_Amount > 100,000 Then Write “Invalid Amount, please try again.” Call Canadian Module Else US_Dollar = Currency_Amount * 6.2561 Call Output Module End French Module Exit Module Declare Quit_Program as string Write “Are you sure you want to Quit? Y/N” Input Quit_Program If Quit_Program = “N” or “n” Then Call Input Module Else If Quit_Program = “Y” or “y” Then End Else

IT 210


Control Flow Diagram—Convert Currency

Write “That was the wrong answer, let’s try that” Write, “one more time, with a Y or N answer.” Call Exit Module End Exit Module Output Module Declare Currency_Amount as real Declare Nationality as string Declare US_Dollar as real Write, “The value of “; Currency_Amount;” ”; Nationality;” is “; US_Dollar” U.S. Dollars Write, “Press any key to return to Main Menu” Pause Call Input Module End Output Module

Menu Error Test Test Results 1: Inputs: Currency_Type = “J” Expected Output: Invalid entry. Make a selection between 1 and 6. Make selection now. Test Results 2: Inputs: Currency_Type = “0” Expected Output: Invalid entry. Make a selection between 1 and 6. Make selection now. Test Results 3: Inputs: Currency_Type = “7” Expected Output: Invalid entry. Make a selection between 1 and 6. Make selection now.

IT 210


Control Flow Diagramâ&#x20AC;&#x201D;Convert Currency

Currency Conversion Test Test Results 1: Valid International Currency = Canadian Inputs: Currency_Type = 1 Currency_Amount = 1.00 Expected Output: US_Dollar = .973 Test Results 2: Valid International Currency = Mexican Inputs: Currency_Type = 2 Currency_Amount = 1.00 Expected Output: US_Dollar = 12.05 Test Results 3: Valid International Currency = English Inputs: Currency_Type = 3 Currency_Amount = 1.00

Expected Output: US_Dollar = .617 Test Results 4: Valid International Currency = Japanese Inputs: Currency_Type = 4 Currency_Amount = 1.00 Expected Output: US_Dollar = 82.26 Test Results 5: Valid International Currency = French Inputs: Currency_Type = 5 Currency_Amount = 1.00 Expected Output: US_Dollar = .716 Test Results 6: Valid International Currency = Quit Inputs: Currency_Type = 6 Expected Output: End program

Test for errors Test Case 1: Valid International Currency = Canadian Inputs: Currency_Type = 1

IT 210


Control Flow Diagramâ&#x20AC;&#x201D;Convert Currency

Currency_Amount = 0 Expected Output: Invalid entry make a selection between 1 and 6 Test Case 2: Valid International Currency = Mexican Inputs: Currency_Type = 2 Currency_Amount = 6 Expected Output: Invalid entry, enter correct dollar amount Test Case 3: Valid International Currency = English Inputs: Currency_Type = Canadian Currency_Amount = 100.0 Expected Output: Invalid entry, make a selection between 1 and 6 Test Case 4: Valid International Currency = Japanese Inputs: Currency_Type = 4 Currency_Amount = 0 Expected Output: Invalid entry, enter currency amount > 0 Test Case 5: Valid International Currency = French Inputs: Currency_Type = 1000000 Currency_Amount = 100.0 Expected Output: Invalid entry make a selection between 1 and 6

Output Testing Test Case 1: Valid International Currency = Canadian Inputs: Currency_Type = 1 Currency_Amount = 1.00 Expected Output: The value of 1 Canadian Dollars is .973 U.S Dollars Press any key to return to Main Menu Test Case 2: Valid International Currency = Mexican Inputs: Currency_Type = 2 Currency_Amount = 1.00 Expected Output: The value of 1Mexican Pesos is .082 U.S Dollars Press any key to return to Main Menu

IT 210


Control Flow Diagramâ&#x20AC;&#x201D;Convert Currency

Test Case 3: Valid International Currency = English Inputs: Currency_Type = 3 Currency_Amount = 1.00 Expected Output: The value of 1 English Pounds is 1.61 U.S Dollars Press any key to return to Main Menu Test Case 4: Valid International Currency = Japanese Inputs: Currency_Type = 4 Currency_Amount = 1.00 Expected Output: The value of 1 Japanese Yen is 0.12 U.S Dollars Press any key to return to Main Menu Test Case 5: Valid International Currency = French Inputs: Currency_Type = 5 Currency_Amount = 1.00 Expected Output: The value of 1 French Francs is 1.39 U.S Dollars Press any key to return to Main Menu Test Case 6: Valid International Currency = Quit Inputs: Currency_Type = 6 Expected Output: Quit? Y/N

IT 210


Control Flow Diagramâ&#x20AC;&#x201D;Convert Currency

Design

Currency Converter Select currency to be converted 1. Canadian Dollars 2. Mexican Pesos 3. English Pounds 4. Japanese Yen 5. French Francs 6. Quit Select 1-6

Currency Amount

IT 210


currency  

my first wriiten program

Advertisement
Read more
Read more
Similar to
Popular now
Just for you