Answered step by step
Verified Expert Solution
Question
1 Approved Answer
currencies.txt is provided by course Algorithm solution to the problem: Prompt the user to enter source currency and store the input to variable sCurrency Prompt
currencies.txt is provided by course
Algorithm solution to the problem:
Prompt the user to enter source currency and store the input to variable sCurrency
Prompt the user to enter target currency and store the input to variable tCurrency
Prompt the user to enter original amount and store the input to variable a
Convert string variable a to float and store it to variable amount
Open File "currencies.txt for read and assign the file object IO channel to variable
The whole content of the file object is read and stored in variable content
Close IO channel f
The items in string content is split based on separator and stored in a list variable
lines.
For each line in List lines
Split line into a list items
Retrieve the first item currency code from list items and assign to variable code
Retrieve the second item from list items and assign it to variable
Convert variable to float and assign it to variable quantity
If code equals to sCurrency
Assign quantity to variable sValue
If code equals to tCurrency
Assign quantity to variable tValue
Calculate amount tValuesValue and assign it to variable result
Display the message with original currency and amount that equals target currency and
amount result
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started