USING VISUAL STUDIO COMMUNITY Currency : BY USING VISUAL STUDIO Write a program
ID: 3597289 • Letter: U
Question
USING VISUAL STUDIO COMMUNITY
Currency : BY USING VISUAL STUDIO Write a program that will convert U.S. dollar amounts to Japanese yen and to euros, storing the conversion factors in the constants YEN_PER_DOLLAR and EUROS_PER_ DOLLAR. To get the most up-to-date exchange rates, search the Internet using the term “currency exchange rate”. If you cannot find the most recent exchange rates, use the following:
1 Dollar = 98.93 Yen
1 Dollar = 0.74 Euros
Format your currency amounts in fixed-point notation, with two decimal places of precision, and be sure the decimal point is always displayed. C# language
Explanation / Answer
using System;
public class Test
{
public static void Main()
{
//constants for currency conversion
const double YEN = 113.53;
const double EURO = 0.85;
Console.WriteLine("Enter the currency in Dollars : ");
double dollars = Convert.ToDouble(Console.ReadLine());
double yens = dollars*YEN;
double euros = dollars*EURO;
//format to fixed point and 2 decimal places
Console.WriteLine("Currency in YEN {0:0.00}", yens);
Console.WriteLine("Currency in EURO {0:0.00}", euros);
}
}
Output:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.