1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Volgvan
2 years ago
15

Write an if-else statement for the following: If user_tickets is less than 5, assign 1 to num_tickets. Else, assign user_tickets

to num_tickets. Sample output with input: 3 Value of num_tickets: 1

Computers and Technology
1 answer:
lesya [120]2 years ago
3 0

Answer:

Please find the answer in the attached image.

Explanation:

I wrote this program using JavaScript programming language.

// A function to check tickets

function tickets(user_tickets){

var num_tickets;

if (user_tickets < 5) {

 num_tickets = 1;

 return ('num_tickets: '+ num_tickets);

}

else {

 num_tickets = user_tickets;

 return('num_tickets: '+ num_tickets);

}

}

// Testing the tickets function

// With user_tickets = 3, 5, 8, and 1

console.log(tickets(3));

console.log(tickets(5));

console.log(tickets(8));

console.log(tickets(1));

You might be interested in
Which argument forces a writer to return to and change the input before resolving a “UnicodeError”?
garri49 [273]

Answer:

B

Explanation:

3 0
3 years ago
In the Happy Valley School System, children are classified by age as follows:less than 2, ineligible2, toddler3-5, early childho
Greeley [361]

Answer:

int age = 10;

switch (age){

case 0:

case 1:

System.out.println("ineligible");

break;

case 2:

System.out.println("toddler");

break;

case 3:

case 4:

case 5:

System.out.println("early childhood");

break;

case 6:

case 7:

System.out.println("young reader");

break;

case 8:

case 9:

case 10:

System.out.println("elementary");

break;

case 11:

case 12:

System.out.println("middle");

break;

case 13:

System.out.println("impossible");

break;

case 14:

case 15:

case 16:

System.out.println("high school");

break;

case 17:

case 18:

System.out.println("scholar");

break;

default:

System.out.println("ineligible");

}

Explanation:

In java and many other programming languages, a switch statement is a way of having multiple branching options in a program. This is usually considered a more efficient way than using multiple if....else if statements. and the expression variables could be byte, char int primitive data types. etc. every branch (option) in a switch statement is followed by the break statement to prevent the code from "falling through". In the question The variable age is declared as an int and initialized to 10. and tested against the conditions given in the question.

7 0
3 years ago
Write a MIPS assembly language program that prompts for a user to enter a series of floating point numbers and calls read_float
LenaWriter [7]

Explanation:

Here if the value in the register $f2 is equals to the value in $f4, it jumps to the Label1. If it should jump when the value in the register $f2 is NOT equals to the value in $f4, then it should be

4 0
3 years ago
Which of the following is NOT a career in the Information Support and Services pathway?
frosja888 [35]

Answer:

here yuuuurrrrr Vote for me nah jk

6 0
2 years ago
Omar sends a PDF file to his teacher. He then prepares another copy of the presentation that includes only the slides he wants t
maria [59]

Answer:

D. Custom Slide Show

Explanation:

Correct on edg

7 0
3 years ago
Other questions:
  • Explain what a dam is and what it does
    12·1 answer
  • Which of the following can be sources of sediment? A. fragments of other rocks B. chemicals and minerals dissolved in water C. s
    11·1 answer
  • Write a SELECT statement that joins the Categories table to the Products table and returns these columns: category_name, product
    5·1 answer
  • Which of the following components does a typical two stroke engine contain
    7·2 answers
  • How to solve 3(x - 2) = 9x<br><img src="https://tex.z-dn.net/?f=3%28x%20-%202%29%20%3D%209x" id="TexFormula1" title="3(x - 2) =
    14·1 answer
  • What types of roles are there as a webmaster?
    6·2 answers
  • Radio and television are examples of
    9·1 answer
  • Which symbol is at the beginning and end of a multiline comment block? &amp;&amp;&amp; """ %%% ###
    5·1 answer
  • A company has a hybrid ASP.NET Web API application that is based on a software as a service (SaaS) offering.Users report general
    9·1 answer
  • Which of the following shows the correct order of inventions that helped the first computers make calculations?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!