It is a bus ticket booking code which is based on the free bus for women and also charges amount for men.
Requirements:
1. Name of passenger
2. We have different stages.. you have to choose one
3. It automatically calculate charge and print ticket
4. You have to enter m / f. ( M for Men and F for Female)
5. If you enter f it is considered as female and amount will be calculated as 0
6. If you enter m it is considered as mentioned and calculate charge according to distance.
7. The stages are related my area you need to change them as you required
Source code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Busticket
{
class Program
{
static void Main(string[] args)
{
string fromname="";
string destname="";
int km, fin = 0, count = 0, er = 0 ;
double amt=0;
Console.Write("Enter Your Name : ");
string name = Console.ReadLine();
Console.Write("Enter Your Gender (m/f): ");
char gender = Convert.ToChar(Console.ReadLine());
if (gender == 'm' || gender == 'f')
{
Console.WriteLine(" 1. Miryalaguda \t 2. Avanthipuram ");
Console.WriteLine(" 3. Alagadapa \t 4. Chillepally ");
Console.WriteLine(" 5. Nereducherla \t 6. LB nagar ");
Console.WriteLine(" 7. Garidepally \t 8. Appannapeta \t 9. Keethavarigudem");
Console.Write("Enter where you enter (1-8): ");
// string[] from1 = { "Miryalaguda", "Avanthipuram", "Alagadapa", "Chillepally", "Nereducherla", "LB Nagar", "Garidepally", "Appannapeta", "Keethavarigudem" };
int from = Convert.ToInt32(Console.ReadLine());
switch (from)
{
case 1:
fromname = "Miryalaguda";
break;
case 2:
fromname = "Avanthipuram";
break;
case 3:
fromname = "Alagadapa";
break;
case 4:
fromname = "Chillepalli";
break;
case 5:
fromname = "Nereducherla";
break;
case 6:
fromname = "LB Nagar";
break;
case 7:
fromname = "Garidepally";
break;
case 8:
fromname = "Appannapeta";
break;
default:
Console.WriteLine("Please enter valid value");
break;
}
Console.WriteLine(" 1. Avanthipuram \t 2.Alagadapa ");
Console.WriteLine(" 3. Chillepally \t 4. Nereducherla ");
Console.WriteLine(" 5. LB nagar \t 6. Garidepally ");
Console.WriteLine(" 7. Appannapeta \t 8. Keethavarigudem");
Console.Write("Enter your destination : ");
int to = Convert.ToInt32(Console.ReadLine());
switch (to)
{
case 1:
destname = "Avanthipuram";
fin = 1;
break;
case 2:
destname = "Alagadapa";
if (from > 1)
{
fin = 1;
}
else if (from == 1)
{
fin = 2;
}
break;
case 3:
destname = "Chillepally";
if (from == to)
{
fin = 1;
}
else if (from < to)
{
for (int i = 1; i <= to; i++)
{
count++;
}
fin = count;
}
else { er++; Console.WriteLine("Invalid selection"); }
break;
case 4:
destname = "Nereducherla";
if (from == to)
{
fin = 1;
}
else if (from < to)
{
for (int i = 1; i <= to; i++)
{
count++;
}
fin = count;
}
else { er++; Console.WriteLine("Invalid selection"); }
break;
case 5:
destname = "LB Nagar";
if (from == to)
{
fin = 1;
}
else if (from < to)
{
for (int i = 1; i <= to; i++)
{
count++;
}
fin = count;
}
else { er++; Console.WriteLine("Invalid selection"); }
break;
case 6:
destname = "Garidepally";
if (from == to)
{
fin = 1;
}
else if (from < to)
{
for (int i = 1; i <= to; i++)
{
count++;
}
fin = count;
}
else { er++; Console.WriteLine("Invalid selection"); }
break;
case 7:
destname = "Appannapeta";
if (from == to)
{
fin = 1;
}
else if (from < to)
{
for (int i = 1; i <= to; i++)
{
count++;
}
fin = count;
}
else { er++; Console.WriteLine("Invalid selection"); }
break;
case 8:
destname = "Keethavarigudem";
if (from == to)
{
fin = 1;
}
else if (from < to)
{
for (int i = 1; i <= to; i++)
{
count++;
}
fin = count;
}
else { er++; Console.WriteLine("Invalid selection"); }
break;
default:
er++;
Console.WriteLine("Please choose valid destination");
break;
}
}
km = fin * 5;
if (gender == 'm')
{
amt = km * 10;
}
else if(gender=='f')
{
amt = 0;
}
else { er++; Console.WriteLine("Invalid Gender"); }
if (er == 0)
{
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("AJ TECH BLOG Bus App");
Console.WriteLine("Welcome " + name);
Console.WriteLine("Express PSGR TKT");
Console.WriteLine(fromname + " - " + destname);
Console.WriteLine("Distance : " + km+" kms");
Console.WriteLine("A1 = " + amt);
Console.WriteLine("Total = " + amt);
Console.WriteLine("Vehicle No. __________");
Console.WriteLine("Thank you for Visiting");
}
Console.ReadLine();
}
}
}