This question already has an answer here:
(amateur highs chool Java coder here). Iv'e been working on this project, and Iv'e reached a problem I can't figure out. Here's what I need help with: (I'm trying to write a program that will determine if the driver is speeding, and if so which one of 3 tickets is suitable, and, how much money to deduct from the account) 1. How do I use the reduc variable in the if statement? I get an error when i Include it in the last if statement like this....
//variables
int sbanka = 400;
int speed = 60;
int speedlimit = 60;
int ticket1 = 100;
//logic
//Ticket 1
if(speed > speedlimit + 10) {
System.out.println("You will recieve the level 1 ticket");
boolean reduc = true;
}
else {
System.out.println("Your speed was fine.");
}
//bank account calculation for ticket 1
if(reduc == true && sbanka >-100) {
sbanka -= 100;
System.out.println("we will deduct 100 dollars from your checking account");
Aucun commentaire:
Enregistrer un commentaire