Q1) Complete the following program c++ by writing a switch statement that displays “one” if the user has entered 1, "two” if the user has entered 2, and "three" if the user has entered 3. If a number other than 1, 2, or 3 is entered, the program should display an error message. #include int main() int userNum; cout << "Enter one of the numbers 1, 2, or 3: "; cin >> userNum; // Write the switch statement here. return 0;
Q: Write a single C statement to accomplish each of the following: d) Calculate the remainder after q…
A: Step 1:- Program Approach:- 1.Include header file 2.Declare variables 3.Take the input from the…
Q: Create a C function that will input 10 numbers and will perform the following 1. Display all even…
A: I give the code in C along with output and code screenshot
Q: Exercise 3: Write a complete C++ program that prompts the user to enter three numeric values; it…
A: Exercise3: #include <iostream> using namespace std; int main(){ int num1,num2,num3;…
Q: Question #4: Use for statement to write a C program that asks the user to enter a positive integer…
A: Code: #include <stdio.h>int main(){ //declaring required variables int n,i;…
Q: :010: Answer the following Question Write a C++ program that displays the results of the expressions…
A:
Q: Question #4: Use for statement to write a C program that asks the user to enter a positive integer…
A: C program for above : #include <stdio.h> int main(void) { //prompt user to enter a…
Q: b) Write complete C Program that will ask the user to enter height (Feet) and weight (Kg) of the…
A: Given: We are given a table that contains categories of people with corresponding heights and range…
Q: Q1-Use ? operator to write C++ program to find the value of the variable Z if you know that.(do not…
A: ? is called as ternary operator This return s the first expression if condition is true or else…
Q: Program2: function Write a program that prompt the user to enter two positive integer numbers x and…
A: C++ Program for above : #include <iostream> using namespace std; int main() { //get…
Q: Q1-Use ? operator to write C++ program to find the value of the variable Z if you know that.(do not…
A: As per the question we have to calculate the value of Z using the given conditions. We have to use…
Q: Q1: Write a C++ program to calculate the volume of a pyramid. Users are required to enter the…
A: Formula Used in Program: 1. Triangular ( triangular base) : Formula - : (1/6) * a * b * h 2. Square…
Q: B- Write C++ statement to accomplish each of the following. 4. Assign the sum of x and y to z and…
A: 4. Assign the sum of x and y to z and increment the value of x by I after the calculation.…
Q: Problem #1: Car experts recommend changing your air filter as often as every 6000 miles if the oil's…
A: Declare two variables, char which stores category A or B and int which store miles in number.…
Q: In this lab, you add the input and output statements to a partially completed C++ program. When…
A: Given data is shown below: In this lab, you add the input and output statements to a partially…
Q: Q1-Use ? operator to write C++ program to find the value of the variable Z if you know that.(do not…
A: Hello Student, hope you are doing well, I will be trying my best to explain and fulfill your query.…
Q: c. Write aprogram using nested if statements that perform the following test: If the variable…
A: Write a program using nested if that will the following conditions and then display the result.…
Q: Question #4: Use for statement to write a C program that asks the user to enter a positive integer…
A: required:
Q: 2. Write C++ declaration statement to accomplish each of the following: Problem C++ Statement…
A: There is the difference between the declaring the variable and initializing the variable When we…
Q: Using switch statement, write program c++ that displays the following menu for the food items…
A: Program Approach:- Use one header file Declare 3 variable of type integer Use switch case for the…
Q: Use for statement to write a C program that asks the user to enter a positive integer number n. Then…
A: From the sequence, it is clear that the numbers getting decreased by 3 and continued till 0
Q: Question #4: Use for statement to write a C program that asks the user to enter a positive integer…
A: #include <stdio.h> int main() { int num,j=0; printf("\n enter the number"); scanf("%d",…
Q: Practice time!!!! 1. Write a C program that will ask the user to input 20 integers. The program will…
A: Answering one question as per the guidelines. The problem is based on the basics of loops in C…
Q: Q1-Use ? operator to write C++ program to find the value of the variable Z if you know that.(do not…
A: GIVEN:
Q: 2. Use a structure called Time to write a C++ program that asks the user to enter a time value in…
A: STRUCT is a C++ data structure that is created to store together elements of different data types.…
Q: Please use C++ and Only Use Selection Statements PROBLEM: Consider the elevator in the Faculty of…
A: I have provided C++ CODE along with CODE SCREENSHOT and TWO OUTPUT…
Q: Q4\A) Use (switch statement) to write a program in C++ to show company structure. If the enter is…
A: Q4) A) Code in c++: #include <iostream> using namespace std; int main() { char oper;…
Q: Code, compile and execute a C++ program that accepts the x and y coordinates of two points. The…
A: Read the value of x1 and x2 and the value of y1 and y2 . Find the value Xm and Ym by using the…
Q: Write a C statement to accomplish each of the following tasks.c) Set variable sum to 0.
A: The setting of a variable to some value can be done using assignment operator.
Q: Q1) How to use C code to write a C program segment to prompt a user for entering an integer and save…
A: use while infinite loop to display warning message until user choose option as 1 , 2 or 3.
Q: Problem #1: Car experts recommend changing your air filter as often as every 6000 miles if the oil's…
A: Actually, Java is a programming language originally developed by James Gosling at Sun Microsystems…
Q: C program: The user should enter a number and then the next consecutive numbers are printed in. How…
A: The user should enter a number and then the next consecutive numbers are printed in. How would I…
Q: 1. Write a C++ program that prompts the user to enter 10 characters and displays if each one is a…
A: // As per our guidelines we are supposed to answer only one question. Kindly repost other questions…
Q: 21: Write a C++ program to calculate the diagonal of a rectangle. Users are required to enter Ehe…
A:
Q: C- Write C++ statement to accomplish each of the following. 7. Dečlare variables sum and x to be of…
A: //Importing library#include <iostream>using namespace std;//Main of the codeint main(){ //7th…
Q: 8. Write C++ statements to accomplish each of the following: a) In one statement, assign the sum of…
A: we have to perform following operations: a) z = ++x + y b) we can use loop and if statement to…
Q: C++ Ex: Write a program to receive an arithmetic operator and two integers, the program performs the…
A: Find Your Code Below
Q: 3. Write a C program which will take two real numbers and a character from the keyboard. a. The…
A: #include <stdio.h> int main(){ float num1, num2; char op; printf("Enter operator: ");…
Q: How to use C code to write a C program segment that prompts and accepts the age and number of hours…
A:
Q: a) Rewrite the following code segment in C++ switch statement: if (grade >='A' && grade <= 'C') cout…
A: code snippet:
Q: Use c code to write a C program that reads a body temperature as 1 (greater and equal to 37 Celsius)…
A: Here we need to use nested switch statement.
Q: Q1-Use ? operator to write C++ program to find the value of the variable Z if you know that.(do not…
A: Algorithm : Step 1 : declare variables. Step 2 : ask for the value of A from user. Step 3 : ask for…
Q: Q1: Write a C++ program to calculate the volume of a pyramid. Users are required to enter the…
A: the answer is given below:-
Q: Design a C++ program to do the administration for a fun run competition. Participants can run a…
A: Registration fees for club members are as follows:5km = R 65.0010km = R 100.0015km = R 150.00…
Q: A 4th grader is having trouble with Permutation and Combination problem in Mathematics, so a friend…
A: #include <iostream> using namespace std;int findFact(int n){ return n == 1 ? 1 : n *…
Q: Q1a) Instructions Consider the following program segment: //inc
A: // header for input output#include <iostream>using namespace std; // for without std int…
Q: Write a C statement to accomplish each of the following tasks.b) Set variable x to 1
A: Here we have a variable x and it needs to be set to value 1.
Q: Q1-Use ? operator to write C++ program to find the value of the variable Z if you know that.(do not…
A: Given that ? Is conditional operator Evaluate using formula is Z = (A+pow(sin(A),2) >…
Q1) Complete the following program c++ by writing a switch statement that displays “one” if the user has entered 1, "two” if the user has entered 2, and "three" if the user has entered 3. If a number other than 1, 2, or 3 is entered, the program should display an error message.
#include <iostream.h>
int main()
int userNum;
cout << "Enter one of the numbers 1, 2, or 3: ";
cin >> userNum;
// Write the switch statement here.
return 0;
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- Problem Statement: C++ PROGRAM A 4th grader is having trouble with Permutation and Combination problem in Mathematics, so a friend offered help to create a program they can use. The program contains 3 options, 1st option is for Permutation, 2nd option is Combination and 3rd is for terminating the system. For option 1, Permutation, they uses the following formula: nPr = ; where r must not be greater than n. It should not proceed if this condition is not met. For 2nd option, Combination, they uses the formula : nCr = ; where r must not be greater than n as well. For the 3rd option, the program owner’s information shall be displayed, like name, subject code and account number, before the program terminates. Requirements: Develop the required system and use cpp for the file name Remember that both n and r are variables, their values shall only be entered at run time. The program requires the use of any looping The program requires the use of any conditional Introduce…Q1) How to use C code to write a C program segment that prompts and accepts the age and number of hours the customer has spent in the “FUNNY Theme Park”. Then, displays the charges based on the rates shown in Figure 2 below : Age Range Rate ( per hour)(RM)0-20 1.0021-50 3.50Above 50 2.00 (Figure 2) In your program, you have to make use of THREE(3) different defined constants for the value of rate per hour and declare the necessary variables.(Apartment problem) A real estate office handles, say, 50 apartment units. When the rent is, say, $600 per month, all the units are occupied. However, for each, say, $40 increase in rent, one unit becomes vacant. Moreover, each occupied unit requires an average of $27 per month for maintenance. How many units should be rented to maximize the profit? Write a program in C++ that prompts the user to enter: The total number of units. The rent to occupy all the units. Amount to maintain a rented unit. The increase in rent that results in a vacant unit. The program then outputs: The number of units to be rented to maximize the profit The maximum profit Since your program handles currency, make sure to use a data type that can store decimals with a decimal precision of 2.
- Design a C++ program to do the administration for a fun run competition. Participants can run a distance of 5 kilometers, 10 kilometers or 15 kilometers. Ask the user if they wish to register a participant (Y or N). Ask whether the person is a member (Y or N)Ask the distance that the person wishes to run (5, 10, 15). Information on using a switch statement for Y or N questions can be found in Beginning C, page 119.You may choose whether to use switch statements, if statements, or both for this practical. Registration fees for club members are as follows:5km = R 65.0010km = R 100.0015km = R 150.00 Non-members:For the 5 and 10 kilometers distances, the participation fees must be increased by 25%For the 15 kilometer distance the registration fee is double that of club members. Use the given criteria and input information to calculate the registration fee. The program must keep track of the total number of participants per distance category, the total amount received per distance…Please use C++ and Only Use Selection Statements PROBLEM:Consider the elevator in the Faculty of Engineering (5-storey). Write a program that accepts the floor number where a passenger (student/faculty/other personnel) will ride the elevator. The passenger can then input the target destination floor. SPECIFICATIONS:- Passengers can ride on any floor (1,2,3,4 or 5).- The program will prompt the user with the target destination floor. After the user input:- Program will display the floors which the elevator passes through, and finally the destination floor.- Elevator will not move if the input for the destination floor is the same as the present floor. The program will notify the user and then terminate.- Program will also terminate if the input destination is not 1,2,3,4 or 5- You’re free to format the input/output display.- Observe proper code indention- All lines should have a comment TEST CASES: If the starting floor is 1 and the destination floor is 5, The program will display: “…Q1) How to use C code to write a C program segment to prompt a user for entering an integer and save it into an “option”variable. In your program, you have to make sure the value (option) entered by the user is either1, 2 or 3 only. Otherwise, display a message asking the user to re-enter the “option” value.[Note: Assume that all the necessary variables have been declared]
- .c program The Problem Statement You and your roommates go through a lot of orange juice. Since you're living on a college budget, you've decided that it's critical for you to take advantage of the "Buy One Get One" (BOGO) free offers at the nearby grocery store. Program Setup Your C program should ask the user to enter the price of one carton of juice as well as the number of cartons being purchased. Note that since juice is an ordinary grocery item, no sales tax is charged on it. Then, determine the final cost of buying orange juice under the BOGO offer. While it is possible to make a solution that does not use If Statements, the purpose of the assignment is to practice with conditions. Make sure you take this opportunity to get the practice you need to master the programming concepts. You'll need to account for two different cases: buying an even number of OJ cartons and buying an odd number of OJ cartons. How can you determine if a number is even or odd? A number that is…(Biology) The number of bacteria, B, in a culture that’s subject to refrigeration can be approximated by this formula: B=300000e0.032t e is Euler’s number 2.71828 (rounded to five decimal places). t is the time in hours the culture has been refrigerated. Using this formula, write, compile, and run a C++ program that prompts the user for a value of time, calculates the number of bacteria in the culture, and displays the result. For testing purposes, check your program by using a test input of 10 hours. After verifying your program, use it to determine the number of bacteria in the culture after 12, 18, 24, 36, 48, and 72 hours.(Numerical) a. Write a C++ program that accepts an integer argument and determines whether the passed integer is even or odd. (Hint: Use the % operator.) b. Enter, compile, and run the program written for Exercise 8a.
- C++ Programming Problem: To make telephone numbers easier to remember, some companies use letters to show their telephone number. For example, using letters, the telephone number 438-5626 can be shown as GET LOAN. In some cases, to make a telephone number meaningful, companies might use more than seven letters. For example, 255-5466 can be displayed as CALL HOME, which uses eight letters. Write a program that prompts the user to enter a telephone number expressed in letters and outputs the corresponding telephone number in digits. If the user enters more than seven letters, then process only the first seven letters. Also output the hyphen after the third digit. Allow the user to use both uppercase and lowercase letters as well as spaces between words. Moreover, your program should process as many telephone numbers as the user wants.Q1) Use c code to write a C program that reads a body temperature as 1 (greater and equal to 37 Celsius) or 2 (less than 37 Celsius). Then read the symptoms as S= sore throat, F= fever and B=breathing difficulty. Your program will display the result accordingly as per table below. You are required to use nested switch. (table as below)the C++ statement that computes h