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
3 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]3 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
What is logical memory?
Eva8 [605]
Logical memory is the address space, assigned to a logical partition, that the operating system perceives as its main storage.
6 0
3 years ago
Why students might want headsets for their computers?
VARVARA [1.3K]
It can be noisy and distracting to students to listen to audio speakers when there are multiple computers in the classroom. Headphones help the students
3 0
3 years ago
What is your personal definition of life? How do you appreciate life?​
kompoz [17]
The definition of life is to fulfill your purpose.To accomplish your goals and enjoy life.Appreciate the little things that happen in your life and look out for others and love unconditionally.Have a positive attitude in life.Love Yourself!
3 0
3 years ago
Write a function that accepts an argument for a persons name. The method should loop through the number of characters in the nam
MatroZZZ [7]

Answer:

#include <iostream>

#include<string.h>

using namespace std;

void printCharacter(string name){

   for(int i=0;name[i]!='\0';i++){

       cout<<name[i]<<endl;

   }

}

int main()

{

   string name;

   cout<<"enter the name: ";

   cin>>name;

   printCharacter(name);

}

Explanation:

first include the two libraries iostream for input/output and string library for using the string.

then, create the main function and declare the variable type string.

cout instruction is used o display the message on the screen.

cin is used to store the value in the name variable.

after that, call the function. The program control move to the the function. In the function for loop is used to print the character one by one until end of the name.

4 0
3 years ago
What is Function of print statement?
trasher [3.6K]

Answer:

To print the statement in the output.

Explanation:

Im a student of C4 and I know this one its In C programming.

6 0
3 years ago
Read 2 more answers
Other questions:
  • Write an expression that evaluates to true if and only if the value of the integer variable workedOvertime is true.
    7·1 answer
  • Which part of the faucet is the aerator?
    13·1 answer
  • Your browsing the Internet and realize your browser is not responding which of the following will allow you to immediately exit
    14·2 answers
  • ______ is an example of unauthorized access to your computer or accounts.
    14·1 answer
  • A function may return a pointer, but the programmer must ensure that the pointer:
    14·1 answer
  • Describe the differences between program development and program execution, including the installed software required for develo
    5·1 answer
  • What should be done with statements or sections which are unclear?
    12·2 answers
  • It takes 2.5 yards of material to make a dress harleys clothing design estimates that they can produce 48 dresses each week.if t
    15·2 answers
  • A local pizza shop is selling a large pizza for $9.99. Given the number of pizzas to order as input, output the subtotal for the
    12·1 answer
  • What are some legal issues that can arise from the use of social media?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!