Write an if-else statement for the following: If userTickets is less than 6, execute award Points = 1. Else, execute award Points = userTickets. Ex: If user Tickets is 3, then award Points = 1.
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
import java.util.Scanner;
public class TicketCounter {
public static void main (String [] args) {
int awardPoints;
int userTickets;
Scanner scnr = new Scanner(System.in);
userTickets = scnr.nextInt(); //
if (userTickets < 6) {
awardPoints = 1;
{
else {
awardPoints = userTickets;
}
System.out.println(awardPoints);
}
}
![12:05 PM Fri Aug 19
= zyBooks
CHALLENGE
ACTIVITY
422784.2543518.qx3zqy7
Jump to level 1
678SSDENT
Ex: If user Tickets is 3, then award Points = 1.
1 import java.util.Scanner;
My library > CS 226T: Java Programming home >
2.1: If-else
Write an if-else statement for the following:
If userTickets is less than 6, execute award Points = 1. Else, execute award Points = userTickets.
4
2.1.3: Basic if-else.
3 public class TicketCounter {
9
10
11
12
13
14
15
16
17
18
19
20
21 }
Check
public static void main (String [] args) {
int award Points;
int userTickets;
if (userTickets < 6) {
award Points 1;
}
{
else {
Scanner scnr = new Scanner(System.in);
userTickets = scnr.nextInt (); // Program will be tested with values: 5, 6, 7, 8.
learn.zybooks.com
award Points = userTickets;
System.out.println(awardPoints);
Try again
1
zyBooks catalog ? Help/FAQ Stacey Queen
2
O+
VPN 100%
B
1
2](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F788fc729-a951-45c4-9909-47eea7bbf82f%2F64de1c8a-6650-41a8-bcc1-bad3d38aae31%2Ftrcy7ph_processed.png&w=3840&q=75)


Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images









