in this program i have multiple if statements similar to this and they print an output just fine. I am new to programming, and have tried multiple times to fix but don't actually know whats wrong, as their are no compile errors.
public class Game
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter Ticket");
String ticket = keyboard.nextLine();
if(ticket.toUpperCase().startsWith("AB")&&(ticket.length() == 8))
{
if(ticket.toUpperCase().charAt(6)=='P'&&(!(ticket.charAt(7)=='1'))&& (ticket.toUpperCase().endsWith("V")))
{
int thirdval = ticket.charAt(ticket.length()-6);
int fourthval = ticket.charAt(ticket.length()-5);
int fifthval = ticket.charAt(ticket.length()-4);
double third = thirdval - '0';
double fourth = fourthval - '0';
double fifth = fifthval - '0';
fourth = fourth/10;
fifth = fifth/1;
double maths = (third + fourth + fifth)*100;
double increase = (maths * 0.15) + maths;
double p = (increase * 0.25) + increase;
double v = increase + 20;
System.out.println("Cost of the ticket is $" + v);
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire