dimanche 28 février 2021

I am getting error: 'else' without "if", why? [closed]

I am getting an error on my first else if. I don't understand why I would have an error what am I missing. Please help.

 if(ticket >=1 && ticket <= 5) {
 discount = cost * 0.00; 
 
 else if(ticket >= 6 && ticket <= 10){
 discount = cost * 0.05;
 }
 else if(ticket >=11){
 discount =cost * 0.10;
 }
 else {
   discount =0;
 }
 
 double totalcost = ticket + Discount;
 double tax = totalcost * 0.07;
 double total = ticket + tax;
 }

Aucun commentaire:

Enregistrer un commentaire