Write an if-else statement for the following:
If userTickets is not equal to 6, execute awardPoints = 10. Else, execute awardPoints = userTickets.
Ex: If userTickets is 14, then awardPoints = 10.
package tickets;
import java.util.Scanner;
public class Tickets {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter user tickets");
int userTickets = scan.nextInt();
int awardPoints;
if(userTickets != 6){
awardPoints = 10;
}
else{
awardPoints = userTickets;
}
System.out.println("The award points is: "+ awardPoints);
}
}
Comments
Leave a comment