Write a program to perform the ATM Transaction.
using System;
using static System.Console;
namespace CSarpExamples
{
class ATMTransaction
{
static void Main()
{
int amount = 1500, withdrow, deposit;
int choice, pin = 0;
WriteLine("Welcome to ATM Service ");
Console.WriteLine();
GoToPIN:
WriteLine("Enter ATM pin number");
pin = int.Parse(ReadLine());
WriteLine();
if(pin == 1111 || pin == 2222 || pin ==3333 || pin == 4444)
{
WriteLine("1. Check the balance\n");
WriteLine("2. Withdrow the cash \n");
WriteLine("3. Deposite your cash \n");
WriteLine("4. Exist");
WriteLine("--------------------------------------------");
WriteLine("Enter your choise : ");
choice = int.Parse(ReadLine());
switch(choice)
{
case 1:
WriteLine("\n Your balance is :{0}", amount);
break;
case 2:
WriteLine("\n Enter Amount to withdrow: ");
withdrow = int.Parse(ReadLine());
if(withdrow % 100 !=0)
{
WriteLine("\n You Enter amount only which isdivisible by 100");
}
else if(withdrow < 100)
{
WriteLine("\n Not accepted amount less than 100");
}
else if(withdrow >2500)
{
WriteLine("\n You can not withdrow amount greater than 2500 ");
}
else
{
amount = amount - withdrow;
WriteLine("\n Please collect your cash");
WriteLine("\n Your current balance: {0}", amount);
}
break;
case 3:
WriteLine("\n Enter the amount deposit");
deposit = int.Parse(ReadLine());
amount = amount + deposit;
WriteLine("\n Your current balance is: {0}",amount);
break;
case 4:
WriteLine("\n Thank uou using ATM");
break;
}
WriteLine("\n\n Thanks for exist ATM Service");
ReadLine();
}
else
{
WriteLine("Pin number is incorrect. Please try again");
goto GoToPIN;
}
ReadLine();
}
}
}
output
using System;
using static System.Console;
namespace CSarpExamples
{
class ATMTransaction
{
static void Main()
{
int amount = 1500, withdrow, deposit;
int choice, pin = 0;
WriteLine("Welcome to ATM Service ");
Console.WriteLine();
GoToPIN:
WriteLine("Enter ATM pin number");
pin = int.Parse(ReadLine());
WriteLine();
if(pin == 1111 || pin == 2222 || pin ==3333 || pin == 4444)
{
WriteLine("1. Check the balance\n");
WriteLine("2. Withdrow the cash \n");
WriteLine("3. Deposite your cash \n");
WriteLine("4. Exist");
WriteLine("--------------------------------------------");
WriteLine("Enter your choise : ");
choice = int.Parse(ReadLine());
switch(choice)
{
case 1:
WriteLine("\n Your balance is :{0}", amount);
break;
case 2:
WriteLine("\n Enter Amount to withdrow: ");
withdrow = int.Parse(ReadLine());
if(withdrow % 100 !=0)
{
WriteLine("\n You Enter amount only which isdivisible by 100");
}
else if(withdrow < 100)
{
WriteLine("\n Not accepted amount less than 100");
}
else if(withdrow >2500)
{
WriteLine("\n You can not withdrow amount greater than 2500 ");
}
else
{
amount = amount - withdrow;
WriteLine("\n Please collect your cash");
WriteLine("\n Your current balance: {0}", amount);
}
break;
case 3:
WriteLine("\n Enter the amount deposit");
deposit = int.Parse(ReadLine());
amount = amount + deposit;
WriteLine("\n Your current balance is: {0}",amount);
break;
case 4:
WriteLine("\n Thank uou using ATM");
break;
}
WriteLine("\n\n Thanks for exist ATM Service");
ReadLine();
}
else
{
WriteLine("Pin number is incorrect. Please try again");
goto GoToPIN;
}
ReadLine();
}
}
}
output
No comments:
Post a Comment