using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Question38623
{
class Program
{
static void Main(string[] args)
{
int pos = 3;
ConsoleKeyInfo key;
Console.WriteLine("Please select your travelling class: \n(use arrows keys UP, DOWN , ENTER - to submit, ESC - Exit)\n");
Console.WriteLine("A - 40kg max *");
Console.WriteLine("B - 25kg max");
Console.WriteLine("C - 15kg max");
do
{
key=Console.ReadKey(true);
switch(key.Key)
{
case ConsoleKey.UpArrow:
Console.SetCursorPosition(18, pos);
Console.Write(" ");
if (pos == 3) pos = 5;
else pos--;
Console.SetCursorPosition(18, pos);
Console.Write("*");
break;
case ConsoleKey.DownArrow:
Console.SetCursorPosition(18, pos);
Console.Write(" ");
if (pos == 5) pos = 3;
else pos++;
Console.SetCursorPosition(18, pos);
Console.Write("*");
break;
case ConsoleKey.Escape: Environment.Exit(0); break;
}
} while (key.Key != ConsoleKey.Enter);
Console.SetCursorPosition(0,8);
Console.Write("Please enter weight of your luggage: (WHOLE number only)\n");
string s_weight ;
long weight;
bool pass;
s_weight=Console.ReadLine();
pass = Int64.TryParse(s_weight, out weight);
if (!pass||weight<0)
{
Console.WriteLine("\nWrong Input. Good Bye");
Console.ReadKey();
Environment.Exit(0);
}
switch (pos)
{
case 3:
if (weight > 40)
{
Console.WriteLine("Additional payment " + ((weight - 40) * 2) + "$");
}
else
{
Console.WriteLine("No Additional payment");
}
break;
case 4:
if (weight > 25)
{
Console.WriteLine("Additional payment " + ((weight - 25) * 2) + "$");
}
else
{
Console.WriteLine("No Additional payment");
}
break;
case 5:
if (weight > 15)
{
Console.WriteLine("Additional payment " + ((weight - 15) * 2) + "$");
}
else
{
Console.WriteLine("No Additional payment");
}
break;
}
Console.Read();
}
}
}
Comments
Leave a comment