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
Because some countries have poor traditional telephone services, companies and consumers have resorted to Group of answer choice
maw [93]

Answer:

a. leap frogging

Question:

Because some countries have poor traditional telephone services, companies and consumers have resorted to Group of answer choices leap frogging. express package services. satellite telephones. fiber-optic telephones. voice over internet protocol (VOIP) services.

3 0
2 years ago
Show the printout of the following code.
alexira [117]

Answer:

E. 7.0

Explanation:

the 7 of the out of the older and make a shame of waves and force of trying

7 0
3 years ago
Which of the following is not true of hardware VPNs?A) should be the first choice for fast-growing networks.B) can handle more t
vfiekz [6]

Answer:

C) have more security vulnerabilities than software

Explanation:

Hardware VPN is a computer term that described a separate tool that serves the functions of a virtual private network. It has its own component and an internal processing unit.

However, some of the characteristics of Hardware VPN is the following:

1. It is expensive compared to software VPN

2. It is generally faster

3. It requires more than a beginner to handle

4. With an in-built firewall, it is generally more secure compared to a software VPN.

Hence, in this case, the correct answer is option C.

3 0
3 years ago
When entering a function or formula in a cell, which of the first character you must type?
lions [1.4K]
When entering a function or formula in a cell, which of the first character you must type =
3 0
3 years ago
Read 2 more answers
Write a program that writes 10 random numbers into a file named numbers using loops.
MariettaO [177]

Answer:

The program in cpp for the given scenario is shown below.

#include <stdio.h>

#include <iostream>

#include <fstream>

using namespace std;

int main()

{

   //object created of file stream

   ofstream out;

   //file opened for writing

   out.open("numbers.txt");

   std::cout << "File opened." << std::endl;

   //inside for loop, random numbers written to numbers.txt using rand()

   for(int n=0; n<10; n++)

   {

       out<<rand()<<endl;

   }

   //file closed

   out.close();

   std::cout << "File closed." << std::endl;

   return 0;

}

Explanation:

1. An object of the ofstream is created. The ofstream refers to output file stream. This is used to create file for write and append operations.

ofstream out;

2. The file named, numbers.txt, is opened using the open() method with the object of ofstream.

out.open("numbers.txt");

3. The message is displayed to the user that the file is opened.

4. Inside a for loop, which executes 10 times, a random number is generated. This random number is written to the file and a new line inserted.

5. The random number is generated using rand() method. Every number is written on  new line.

out<<rand()<<endl;

6. Every execution of the for loop repeats steps 4 and 5.

7. When the loop ends, the file is closed using close() method with the object of ofstream.

out.close();

8. A message is displayed to the user that the file is closed.

9. The header file, fstream, is included to support file operations.

10. The extension of the file can be changed from .txt to any other type of file as per requirement.

11. The program can be tested for writing more numbers to the file.

12. The program can be tested for writing any type of numeric data to the file.

13. The program is written in cpp due to simplicity.

14. In other languages such as java or csharp, the code is written inside classes.

15. In cpp, all the code is written inside main() method.

16.    The screenshot of the output messages displayed is attached.

3 0
2 years ago
Other questions:
  • Which one of the following terms is defined as the material and surfaces upon which an artist works?
    9·1 answer
  • Indicate the proper order (1-4) of the following PR strategic planning 4-step process. 1 Defining the problem 2 Evaluating the p
    10·1 answer
  • The file type ____ identifies a word 2013 document.
    11·1 answer
  • Jody should select the
    5·1 answer
  • What two statements about IPv6 addresses are true? This task contains the radio buttons and checkboxes for options. The shortcut
    7·1 answer
  • Drag each tile to the correct box.
    12·1 answer
  • Which of the following is an example of a logic error?
    9·2 answers
  • Have fire have ....<br><br>babi​ from babi098
    7·1 answer
  • 1. Sunday Times wants an analysis of the demographic characteristics of its readers. The
    8·1 answer
  • What happens if part of an ftp message is not delivered to the destination?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!