I am on semester break and doing old labs. My task here is to design a currency menu system using a switch statement. When I run it in a console, I have to input a number then I have to press the following numbers corresponding to their currency exchange. We I press example 1, it shows up with its constant double.
using System;
namespace Exchange
{
class Program
{
static void Main()
{
const double aud = 0.96, usd = 0.72, pounds = 0.54, yen = 73.83, euro = 0.65, rupees = 48.32, kina = 2.28, rand = 10.46;
double exchange, dollarOne, dollarTwo, dollarThree, dollarFour, dollarFive, dollarSix, dollarSeven, dollarEight;
char inputNumber = ' ';
int number = 0;
string temp;
Console.WriteLine("How much money do you want to exchange?");
temp = Console.ReadLine();
exchange = Convert.ToDouble(temp);
Console.WriteLine("Press 1 for Austrlian Dollars");
Console.WriteLine("2 for US Dollars");
Console.WriteLine("3 for English Pounds");
Console.WriteLine("4 for Japanese Yen");
Console.WriteLine("5 for Euro");
Console.WriteLine("6 for Indian Rupees");
Console.WriteLine("7 for PNG Kina");
Console.WriteLine("8 for SA Rand");
dollarOne = exchange * aud;
dollarTwo = exchange * usd;
dollarThree = exchange * pounds;
dollarFour = exchange * yen;
dollarFive = exchange * euro;
dollarSix = exchange * rupees;
dollarSeven = exchange * kina;
dollarEight = exchange * rand;
temp = Console.ReadLine();
inputNumber = Convert.ToChar(temp);
switch (number)
{
case 0:
inputNumber = '1';
Console.WriteLine("Australian Dollars - " + aud);
break;
case 1:
inputNumber = '2';
Console.WriteLine("US Dollars - " + usd);
break;
case 2:
inputNumber = '3';
Console.WriteLine("English Pound - " + pounds);
break;
case 3:
inputNumber = '4';
Console.WriteLine("Japanese Yen - " + yen);
break;
case 4:
inputNumber = '5';
Console.WriteLine("Euros - " + euro);
break;
case 5:
inputNumber = '6';
Console.WriteLine("Indians Rupees - " + rupees);
break;
case 6:
inputNumber = '7';
Console.WriteLine("PNG Kina - " + kina);
break;
case 7:
inputNumber = '8';
Console.WriteLine("SA Rand - " + rand);
break;
}
Console.ReadLine();
}
}
}
It looks like you're new here. If you want to get involved, click one of these buttons!