You are on page 1of 2

# COP2271 MATLAB Spring 16

Assignment 1

## Due: January 26 at 11:59 pm

Currency Converter
Recreate Googles currency converter to switch a monetary value to another currency.
Key programming concepts: If statements, conditions, logical operators, fprintf precision
Approximate lines of code: 25 (does not include comments or white space)

## Program Inputs and Outputs

Display to the user the following information/questions:
MATLAB Currency Converter: 1) US Dollar 2) Euro 3) Russian Ruble
How much currency to convert?
Currency to convert from:
Currency to convert to:
and your program must display the answer as:
Converted value: XXX YYY where XXX is the final converted value and YYY is the
currency
Conversion not needed... if the user chooses the same currency for both options
Assignment Details
Googles online currency converter has hundreds of different monetary values to choose from:

## Figure 1: Googles currency converter.

Your task is to recreate this program for only three different currencies: US Dollars, Euro,
Russian Ruble. The program will ask the user for how much money to convert and for two
different currencies. You can safely assume the user will always enter valid values for
each question! Here are the various conversion factors to use (note these factors change constantly
online, so use these values!):
1 U S Dollar = 0.9192022 Euro
1 U S Dollar = 78.4782 Russian Ruble
Lastly, your program must display the final answer to only two decimal places since the
value is monetary. This will require the advance syntax of %f format spec in fprintf to get the
correct numeric precision.
1

Assignment 1

## Due: January 26 at 11:59 pm

Sample Output
The following test cases do not cover all possible scenarios (develop your own!) but should
indicate if your code is on the right track:
Test Case 1:
MATLAB Currency Converter: 1) US Dollar 2) Euro 3) Russian Ruble
How much currency to convert? 20
Currency to convert from: 1
Currency to convert to: 2
Converted value: 18.38 Euro
Test Case 2:
MATLAB Currency Converter: 1) US Dollar 2) Euro 3) Russian Ruble
How much currency to convert? 20
Currency to convert from: 1
Currency to convert to: 3
Converted value: 1569.56 Russian Ruble
Test Case 3:
MATLAB Currency Converter: 1) US Dollar 2) Euro 3) Russian Ruble
How much currency to convert? 1000
Currency to convert from: 3
Currency to convert to: 1
Converted value: 12.74 US Dollar
Test Case 4:
MATLAB Currency Converter: 1) US Dollar 2) Euro 3) Russian Ruble
How much currency to convert? 75
Currency to convert from: 2
Currency to convert to: 3
Converted value: 6403.23 Russian Ruble
Test Case 5:
C++ Currency Converter: 1) US Dollar 2) Euro 3) Russian Ruble
How much currency to convert? 50
Currency to convert from: 2
Currency to convert to: 2
Conversion not needed...