Question

In: Computer Science

Write a C++ script to perform the following: a.) Ask a user to enter 2 real...

Write a C++ script to perform the following:

a.) Ask a user to enter 2 real numbers.
b.) Save the user response as a variable a and b.
c.) Display if the numbers are even or odd.
d.) Check if the number a belongs in the interval D = [10, 99], display the output as "a is between 10 and 99" or "a is not between 10 and 99".
e.) Check if the number b belongs in the interval E = [0, 50], display the output as "b is between 0 and 50" or "b is not between 0 and 50".

Solutions

Expert Solution

Code:

#include <iostream>
using namespace std;
int main()
{
   int a,b;
   cout<<"Enter first Number:";          //Taking response from the user
   cin>>a;                               //Storing it to variable
   cout<<"Enter Second Number:";         //Taking response from the user
   cin>>b;                               //Storing it to variable
   if(a%2==0)                            //if condition to check whether 'a' is even or odd
   {
       cout<<"a is a even number:"<<a<<endl;
   }
   else
   {
       cout<<"a is a odd number:"<<a<<endl;
   }
   if(b%2==0)                            //if condition to check whether b is even or odd
   {
       cout<<"b is a even number:"<<b<<endl;
   }
   else
   {
       cout<<"b is a Odd number:"<<b<<endl;
   }
   if(a>10 && a<99)                     //condition to check 'a' is in given range or not
   {
       cout<<"a is in between 10,99"<<endl;
   }
   else
   {
       cout<<"a is not between 10,99"<<endl;
   }
   if(b>0 && b<50)                       //condition to check 'b' is in given range or not
   {
       cout<<"b is in between 0,50"<<endl;
   }
   else
   {
       cout<<"b is not between 0,50"<<endl;
   }
  
}

Reference:

Output:

Note: I have provided you needed information. If face any difficulty in understanding it please comment.If you are satisfied with my answer please upvote....Thank you...


Related Solutions

Write a C++ code to perform the following steps: 1. Ask the user to enter two...
Write a C++ code to perform the following steps: 1. Ask the user to enter two whole numbers number1 and number2 ( Number 1 should be less than Number 2) 2. calculate and print the sum of all even numbers between Number1 and Number2 3. Find and print all even numbers between Number1 and Number2 4. Find and print all odd numbers between Number1 and Number2 5. Calculate and print the numbers and their squares between 2 and 20 (inclusive)...
Write a C++ code to perform the following steps: 1. Ask the user to enter two...
Write a C++ code to perform the following steps: 1. Ask the user to enter two whole numbers number1 and number2 (Number1 should be less than number2) 2. Calculate and print the sum of all even numbers between Number1 and Number2 3. Find and print all even numbers between Number1 and Number2 4. Find and print all odd numbers between Number1 and Number2 5. Calculate and print the numbers and their squares between 1 and 20 (inclusive) 6. Calculate and...
5) Write a JavaScript script that will ask the user to enter in the length of...
5) Write a JavaScript script that will ask the user to enter in the length of the side of a cube. (all the sides of a cube are equal) Based on the value that is entered by the user from the keyboard, calculate each of the following and assign your results to variables. 1. volume of the cube 2. surface area of the cube 3. volume of the largest sphere that could fit in the box. 4. surface area of...
In Kali Linux Write a script that ask the user to enter an IP address and...
In Kali Linux Write a script that ask the user to enter an IP address and a port number, then use the provided entries from the user to perform a query on your local network and determine if the given port is open on the provide network. Need to submit solutions for both below. 1.A short report showing the functionality of your code 2. your bash script
Write a java program that perform the following: 1. Ask a user ti enter 10 student...
Write a java program that perform the following: 1. Ask a user ti enter 10 student test score on a test (100 point test and save the score in an array 2. Iterate through the array to find the average and highest of these score, print them out 3 Count how many student score below average and print them out 4 . Instructor decide to curve the student score using square root curving method( take the square root of the...
Write a program that does the following. It will ask the user to enter an integer...
Write a program that does the following. It will ask the user to enter an integer larger than 1, and the if entered integer is not larger than 1, it keeps prompting the user. After the user enters a valid integer, the program prints all the prime factors of the integer (including the repeated factors). For example, if the entered integer is 24, the program prints: 2 2 2 3 Run your program with the test cases where the entered...
Write in C# please! Ask the user to enter all of their exam grades. Once they...
Write in C# please! Ask the user to enter all of their exam grades. Once they are done, calculate the minimum score, the maximum score and the average score for all of their scores. Perform this using at least 2 Loops (can be the same type of loop) and not any built in functions.
Write a program using C language that -ask the user to enter their name or any...
Write a program using C language that -ask the user to enter their name or any other string (must be able to handle multiple word strings) - capture the epoch time in seconds and the corresponding nanoseconds - ask the user to type in again what they entered previously - capture the epoch time in seconds and the corresponding nanoseconds -perform the appropriate mathematical calculations to see how long it took in seconds and nanoseconds (should show to 9 decimal...
Using C++ Write a program to ask user to enter a password and validity the password....
Using C++ Write a program to ask user to enter a password and validity the password. The password should be 8 – 20 characters long (8 is included and 20 is included), it should contain at least one uppercase letter and one lower case letter. The password should contain at least one digit, and at least one symbol other than alphabets or numbers. Most importantly, the password may not contain any white space. Functions: You will need at least the...
Write a C++ program to ask the user to enter the shape type: square, sphere or...
Write a C++ program to ask the user to enter the shape type: square, sphere or circle and the appropriate dimensions of the shape.. The program should output the following information about the shape: a.for a square. it output the area and perimeter. b. for a sphere, it outputs the area. c. fir a circle, it outputs the volume. if the user input anything else, your program should output: "the program does not recognize this shape". Use const whenever it...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT