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
Masteriza [31]
4 years ago
8

Write an if statement that prints the message ""The number is not valid"" if the variable distance is outside the range 100 thr

ough 2000(both inclusive).
Computers and Technology
1 answer:
Slav-nsk [51]4 years ago
5 0

Answer:

The solution code is written in Python:

  1. if(distance < 100 or distance > 2000):
  2.        print("The number is not valid")

Explanation:

In this question either one of the two conditions (distance < 100 or distance > 2000) is met, the error message should be generated. Python offers the "or" keyword as a logical operator. The "or" keyword will join two conditions and so long as one of them is True, the final outcome will be evaluated to True. For example, if distance = 90 the error message will be printed. If distance is 2500, the error message will also be printed.

You might be interested in
What type of network does not have centralized control, such as one in a small office or home office?
ella [17]
The answer is P.2.P

:)
7 0
4 years ago
Write a program that mimics a calculator. The program should take as input two integers and the operation to be performed. It sh
IgorC [24]

Answer:

The cpp calculator program is as follows.

#include <iostream>

using namespace std;

int main()

{

   //variables to hold two numbers and operation

   int num1;

   int num2;

   char op;

   char operations[] = {'-', '/', '*'};

   std::cout << "Enter first number: ";

   cin>>num1;

   std::cout << "Enter second number: ";

   cin>>num2;

   do

   {

       std::cout << "Enter the operation to be performed(-, /, *): ";

       cin>>op;

       if(op!=operations[0] && op!=operations[1] && op!=operations[2])

           std::cout << "Invalid operator." << std::endl;

   }while(op!=operations[0] && op!=operations[1] && op!=operations[2]);

   std::cout<< "Numbers are "<< num1 <<" and "<< num2 <<std::endl;

   std::cout << "Operator is " <<op<< std::endl;

   if(op==operations[0])

       std::cout << "Result is "<< num1-num2 << std::endl;  

   if(op==operations[1])

       if(num2==0)

           std::cout << "Denominator is zero. Division cannot be performed." << std::endl;

       else

           std::cout << "Result is "<< num1/num2 << std::endl;

   if(op==operations[2])

           std::cout << "Result is "<< num1*num2 << std::endl;

   return 0;  

}

OUTPUT

Enter first number: 12                                                                                                                    Enter second number: 0                                                                                                                         Enter the operation to be performed(-, /, *): +                                                                                                Invalid operator.                                                                                                                              Enter the operation to be performed(-, /, *): /                                                                                                Numbers are 12 and 0                                                                                                                           Operator is /                                                                                                                                  Denominator is zero. Division cannot be performed.

Explanation:

1. Declare two integer variables to hold the numbers.

int num1;

int num2;

2. Declare one character variable to hold the operation to be performed.

char op;

3. Declare one character array to hold all the operations.

char operations[] = {'-', '/', '*'};

4. User input is taken for the two numbers followed by the operation to be performed.

5. Validation is applied for incorrect operation entered by the user. This is done using if statement inside a do-while loop.

6. Once the correct input is obtained, the calculator program performs the required operation on the numbers. This is done using if statements.

7. If the denominator number is zero for division operation, a message is displayed to the user.

8. The numbers followed by the operation chosen by the user are displayed.

9. The result of the operation is computed and displayed.

5 0
3 years ago
Write a C# solution for the following problem. Submit your .cs file to this link. Sample output(s) attached. == Create an Employ
harkovskaia [24]

Answer:

See attached file for detailed solution.

Explanation:

See attached file for explanation.

Download txt
3 0
3 years ago
Describe how the process of sampling, RGB pixels, and binary sequences work together to display a digital color image.
vitfil [10]

The pixels for RBG are built off code.

8 0
4 years ago
Read 2 more answers
An application programming interface (API) is ________. Select one: A. the code to interface between an application and RAM B. t
Olegator [25]

Answer:

An application programming interface (API) is the code the CPU recognizes to perform a procedure in an application.

Explanation:

An application programming interface (API) is the code the CPU recognizes to perform a procedure in an application. API allows an application to communicate with another application, or an operating system, database, network, etc.

An Application Programming Interface (API) creates a consideration for a problem and specifies how clients should interact with software components that implement a solution to that problem.

More recently, API has been used to refer to a specific type of interface between a client and a server, which has been described as a “contract” between both - such that if the client makes a request in a specific format, it will always get a response in a specific format or initiate a defined action.This is a specialized form of API, defined as a Web API.

3 0
3 years ago
Other questions:
  • What does a server do? *
    11·1 answer
  • Write a program with total change amount as an integer input that outputs the change using the fewest coins, one coin type per l
    13·1 answer
  • What is one course of action available in every problem solving process?
    9·2 answers
  • Write a function "nonRepeatings" that takes a string "s3" and returns the non-repeating characters in this string. Sample Input
    11·1 answer
  • Object Oriented Programming (OOP) allows us to handle complex code in an organized structure and break down the problem by model
    5·1 answer
  • Phillip wants to create a new Google Display Ad campaign and base his targeting on an existing remarketing list named Checkout A
    10·1 answer
  • Suppose that the first number of a sequence is x, where x is an integer. Define ; ‍ if is even; ‍ ‍ ‍ if is odd. Then there exis
    11·1 answer
  • Which note taking strategy has you divide a page into 3 sections for your notes, key points, and summary?
    11·1 answer
  • Which gases are carried by red blood cells? Select two options.<br> science question
    14·2 answers
  • How do we store value in a variable? Give an example
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!