Here is the program:
# Purpose:
# This program will convert 3 specified dollar amounts to Danish
# Krones, Euros, and Hong Kong Dollars. The user will enter the
# dollar amounts and the exchange rates.
# Variable Declarations
us_dollars = 0
danish_krones ;
euros ;
hong_kong_dollars ;
number_of_us_dollars = 3 ;
us_dollar_total = 0.0;
danish_exchange;
euros_exchange ;
hk_exchange ;
i ;
import sys;
print("Welcome to the Money Exchange\n\n") ;
print("The program will convert three US dollar amounts to Danish, Krones, Euros and Hong Kong Dollars.\n\n") ;
print("First, please enter the exchange rates:\n\n");
print("Danish Krones: ");
danish_exchange = sys.argv; # Reads the user input for Danish Krones
print("Euros: "); # Reads the user input for Euros
euros_exchange = sys.argv;
print("Hong Kong Dollars: ") ; # Reads the user input for Hong Kong Dollars
hk_exchange = sys.argv;
# Begin for loop
for(i = 1; i <= number_of_us_dollars; ++i)
print("\n\n\nEnter US dollars i to be converted: "); # Dollar amounts are entered by user */
us_dollars = sys.argv;
print("\n The amount of $us_dollars US dollars is equivalent to:\n\n");
danish_krones = us_dollars * danish_exchange ; #US dollars are converted to other currencies */
euros = us_dollars * euros_exchange ;
hong_kong_dollars = us_dollars * hk_exchange ;
print(" danish_krones Danish Krones\n"); # Display dollar value in the other currencies */
print(" euros Euros\n");
print(" $hong_kong_dollars Hong Kong Dollars\n\n");
us_dollar_total = us_dollar_total + us_dollars ; # Accumulator for total US dollars converted */
# End for loop
print("You have converted a total of $us_dollar_total dollars.\n" );

New Topic/Question
Reply



MultiQuote





|