Java Program to write Taxi Program Logic.
How does this program work?
- This code helps to how to write Taxi Program logic.
Here is the code
public class taxi
{
public static void main(String[]args)
{
int c,t,s,e,d,to;
System.out.println("Welcome to UBER\n");
System.out.println("Choose Your Car Number:\n");
System.out.println("1-> AP05 AE 8887\n");
System.out.println("2-> AP05 CK 9875\n");
System.out.println("3-> AP05 CY 2468\n");
Scanner obj8=new Scanner(System.in);
c = obj8.nextInt();
if (c==1)
{
System.out.println("Enter the count of the trips:\n");
Scanner obj0=new Scanner(System.in);
t=obj0.nextInt();
System.out.println("Enter the starting Kilometers of the day started:\n");
Scanner obj=new Scanner(System.in);
s=obj.nextInt();
System.out.println("Enter the Ending Kilometers of the day ended:\n");
Scanner obj1=new Scanner(System.in);
e=obj1.nextInt();
d = e - s;
System.out.println("Your Car Number is AP05 AE 8887\n");
System.out.println("Total Trips count:"+t);
System.out.println("Total Kilometers Driven today is:"+d);
System.out.println("Income per each kilometer: ₹ 8\n");
to = 8 * d;
System.out.println("Total Income::"+to);
}
else if (c==2)
{
System.out.println("Enter the count of the trips:\n");
Scanner obj0=new Scanner(System.in);
t=obj0.nextInt();
System.out.println("Enter the starting Kilometers of the day started:\n");
Scanner obj=new Scanner(System.in);
s=obj.nextInt();
System.out.println("Enter the Ending Kilometers of the day ended:\n");
Scanner obj1=new Scanner(System.in);
e=obj1.nextInt();
d = e - s;
System.out.println("Your Car Number is AP05 CK 9875\n");
System.out.println("Total trips count:"+t);
System.out.println("Total Kilometers Driven today is:"+d);
System.out.println("Income per each kilometer: ₹ 8\n");
to = 8 * d;
System.out.println("Total Income::"+to);
}
else if (c==3)
{
System.out.println("Enter the count of the trips:\n");
Scanner obj0=new Scanner(System.in);
t=obj0.nextInt();
System.out.println("Enter the starting Kilometers of the day started:\n");
Scanner obj=new Scanner(System.in);
s=obj.nextInt();
System.out.println("Enter the Ending Kilometers of the day ended:\n");
Scanner obj1=new Scanner(System.in);
e=obj1.nextInt();
d = e - s;
System.out.println("Your Car Number is AP05 CY 2468\n");
System.out.println("Total trips count:"+t);
System.out.println("Total Kilometers Driven today is:"+d);
System.out.println("Income per each kilometer: ₹ 8\n");
to = 8 * d;
System.out.println("Total Income::"+to);
}
else
{
System.out.println("Wrong Input");
}
}
}