Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

how to do this assigment in C# using visual studio (console application c#) ? Cr

ID: 3780288 • Letter: H

Question

how to do this assigment in C# using visual studio (console application c#) ?

Create an application that prompts the user for a total of purchases, and then converts the total to a foreign currency. The program must run all test cases of purchases in one execution. Use a sentinel value to terminate the program. Output screenshot must include the input values & their converted values.

Rules:

Purchase must be greater than zero. If zero or less, reprompt for that purchase again.

Currency conversions:

$1 USD = 82.66 Japanese Yen

$1 USD = .994 Canadian $

$1 USD = 0.77 Euro

$1 USD = 0.625 British Pound                   

$1 USD = 2.1338 Brazilian Real

$ 1 USD = 6.2686 Chinese Yuan

Run your application with the following data and save the screenshot of inputs and outputs to submit.

Purchase: Convert to:

$ 251.95                         Real

-5.88 replace with $15.88       Yuan

$ 7,206.73 Euro

$ 1,634.72 Yen

$ 599.99 Pound

Explanation / Answer

using System;

public class Program
{
static void Main()
{
   double yen=82.66, can=0.994, eur=0.77, pou=0.625, rea=2.1338, yua=6.2686;
   double val1, val2;
   while (true) // Loop indefinitely
   {
   string str=Console.ReadLine();
   string[] tokens = str.Split(',');
   Console.WriteLine("Purchase: Convert to:");
   val2 = Convert.ToDouble(tokens[1]);
   tokens[2] = tokens[2].Trim();
   bool result = tokens[2].Equals("Exit", StringComparison.Ordinal);
   if(result==true) break;
   if(val2<=0.0) continue;
   if(tokens[2].Equals("Yen", StringComparison.Ordinal)) {
       val1=val2*yen;
       Console.WriteLine("{0} Yen",val1);
   }
   if(tokens[2].Equals("Canadian", StringComparison.Ordinal)) {
       val1=val2*can;
       Console.WriteLine("{0} Canadian $",val1);
   }
   if(tokens[2].Equals("Euro", StringComparison.Ordinal)) {
       val1=val2*eur;
       Console.WriteLine("{0} Euro",val1);
   }
   if(tokens[2].Equals("Real", StringComparison.Ordinal)) {
       val1=val2*rea;
       Console.WriteLine("{0} Real",val1);
   }
   if(tokens[2].Equals("Yuan", StringComparison.Ordinal)) {
       val1=val2*yua;
       Console.WriteLine("{0} Yuan",val1);
   }
   if(tokens[2].Equals("Pound", StringComparison.Ordinal)) {
       val1=val2*pou;
       Console.WriteLine("{0} Pound",val1);
   }
   }
}
}