Q2- Write a program to find the value of A (use switch statement): A=x+b when k=1 A=x-b when k=2 A=x*b when k=3 A=x/b when k=4 Note: x,b,k are numbers entered by the user.
Q: Program IV: The Tuition Part Write a program that prompts the user to enter the number of courses…
A: C++ used to answer this question
Q: Rewrite the following code segment using if-else statement instead of switch statement: switch (i) {…
A: 1)Code: using if else: //rewriting of the code using if else statements instead of switch statement…
Q: (a) Write a Boolean expression that evaluates to true if a number stored in variable num is between…
A: a) (num >1) && (num < 100) Eg:- sample program Public class main { Public static void…
Q: Rewrite the following code segment using if-else statement instead of switch statement: switch (i)…
A: If-else statements are used in case of conditional programming.
Q: Determine whether the following is a valid switch statement. if not, explain why. Assume that n and…
A: Rules for switch statement: An expression must always execute to a result. Case labels must be…
Q: Q3) Using switch statement, write program that displays the following menu for the food items…
A: #include<iostream>#include<conio.h> #define B 10;#define F 6;#define P 14;#define S 8;…
Q: Rewrite the following program using switch statements. 1/Set 7.3 #include #include using namespace…
A: Step 1: Accept choice x from user Step 2: Switch to choice x case 1 print "you select…
Q: Days in a month Write a program that asks the user to enter a month (1 for January, 2 for February,…
A: C++ Program for above : #include<iostream> using namespace std; int main() { //prompt…
Q: Q2- Write a program to find the value of A (use switch statement): A=x+b when k=1 A=x-b when k=2…
A: NOTE: Programming language is not mentioned so doing in C++ In this question, we are asked to write…
Q: لغة اسمبلي 1- Write a program to read a letter in lower case then convert this letter to upper case…
A: 2.
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: b- Write a program that uses a switch statement to determine if the number is odd or even for…
A: The syntax of switch statement is switch(condition) { case : // statement to be executed Break;…
Q: Positions on a chess board are identified by a letter and a number. The letter identifies the…
A: The chessboard is a game board where two players move the pawns on the board of size 8x8. The…
Q: Write a complete program that: 1. Prompts the user to enter a letter grade and reads in a letter…
A: The answer is given below:-
Q: Q/The equivalent statements for the following code are for(i=4;i>=0; i--) switch (i) {case 0:…
A: The correct answer is There is no right choice. The given code has few missing elements which does…
Q: Q8-Write a program to convert a test score into its equivalent letter grade (Use switch statement):…
A: /*C Program to convert a test score to its equivalent letter grade using switch statement*/…
Q: Q1: b- Write a program that uses a switch statement to determine if the number is odd or even for…
A: Provided the C++ program which uses a switch statement to determine whether number is odd or even…
Q: Q2. If y=nthroot(X,2)-4 Write a program to calculate values of y for every x if x is from 1 to 10
A: Use a for loop to iterate over the values from 1 to 10
Q: 2. Write a switch statement that follows this pseudocode: prompt the user to enter a code (P to S)…
A: Code: #include <stdio.h>int main(){ //declared a variable named grade char grade;…
Q: Using switch statement, write program c++ that displays the following menu for the food items…
A: Algorithm Start Char c, int q Accept dish from user Accept quantity from user Calculate total price…
Q: Q2)- Write a program to enter a number from the keyboard, then check: -if the number is bigger than…
A: Given: -
Q: 1. Write a program using switch statement to display the days of the week. For example if the user…
A: The given problem is related to java where the requirement is to provide a java program. **The…
Q: A mail order shop sells ten different products whose retail prices are shown in the following table:…
A: As no programming language is mentioned I will be using C++ to code.
Q: Q5: - Write program to calculate the equation sin(x) y(x) = x* where x 0.1, 0.2,0.3,0.4 Use a combo…
A: Problem Analysis : Note: Since programming language is not mentioned therefore answering the…
Q: Use a switch statement instead of the if/else if statement.
A: #include <iostream>using namespace std;int main(){char selection;cout << "Enter your…
Q: Q11 write a Program to check whether an integer number is positive or negative using (if) statement…
A: prompt = 'Insert a number: '; x = input(prompt); if x < 0 fprintf('Your input is negative…
Q: Re-write the following program by converting IF-ELSE statement to SWITCH statement. #include Using…
A: A switch is a control expression that allows one to choose one option from a list of options. The…
Q: Using Switch statement, write a program that displays the following menu for the food items…
A: Declare a character variable and an integer variable to hold type of food and quantity of food,…
Q: print_pattern() prints 5 characters. Call print_pattern() twice to print 10 characters. Example…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: (a) Assume x, y and z are integer variables and x = 5 and y = 6. Trace and write the values of the…
A: Dear Student, In the case of post increment, it assigns to a variable first, then increases the…
Q: int x = 5, y = 10; switch(x>y && x+y>0) { case 1: printf('hi"); break; case 0: printf("bye"); break;…
A: 1) Above program defines variable x = 5 and y = 10 2) In Switch statement it evaluates expression…
Q: Write a kotlin program for print the values between 5 to 9 at 10 use break statement
A: Here have to determine about the kotlin code for print number.
Q: The following code reads x, and if it is divisible by 5 and positive then it should print "x is…
A: The instructions are provided by the programmer according to the requirement using the programming…
Q: (Calculating Total Sales) A mail order house sells five different products whose retail prices are:…
A: C++ used to answer this question
Q: Problem 2. Write a program that asks the user to enter a number within the range of 1 through 10.…
A: #include <iostream> using namespace std; int main(){ int num; check:…
Q: Q5:- Write program to calculate the equation y(x) = x Use a combo box to choose a suitable value to…
A: Note: Since programming language is not mentioned therefore answering the question in Python…
Q: C++ Write a program to check a number is prime or not. The number must be taken. From user
A: Requirements :- C++ Write a program to check a number is prime or not. The number must be taken.…
Q: Convert the following switch statement to an if-else block. • The output must be the same for all…
A: The equivalent if-else code for the given switch code is below.
Q: C++ Ex: Write a program to receive an arithmetic operator and two integers, the program performs the…
A: Find Your Code Below
Q: Q2- Write a program to find the value of A (use switch statement): A-x+b when k-1 A-x-b when k-2…
A: As no programming language is mentioned it is solved using basic C++
Q: Calculate f(x) using if statement where f(x) -2x when x<O, f(x) = x(x-2) when x is in [O, * .2]
A: Here no language is mentioned so, I have provided c++ code for the given problem.
Q: Q1) By using If-statement, write a program to find the Y value when: 2 ,-10<x < 0 x3 Y = - , X = 0…
A: Since no programming language is mentioned I am using c++ Algorithm: 1. Start 2. Read x value 3. If…
Q: Write switch statement swift program for days in the week.
A: ALGORITHM:- 1. Declare a variable that will hold week Day. 2. Use switch statement on the basis of…
Q: Write C++ program to read two numbers and print multiple if the one of two numbers are multiple of…
A: Hey, since there are multiple questions posted, we will answer first question. If you want any…
Q: -Write a program using if statement instead of switch statement. x=2; switch x case 1;…
A: #include<stdio.h>…
Q: Program IV: The Tuition Part Write a program that prompts the user to enter the number of courses…
A: ****Note: As programing language is not mentioned in the question, using C++ language to solve…
Q: a) Rewrite the following code segment in C++ switch statement: if (grade >='A' && grade <= 'C') cout…
A: code snippet:
Q: program that applies bonus scores to given scores in the range [1.9]. The program eads a digit as an…
A: Question-> Construct a Flowchart Diagram, Pseudocode and write a C++ program that applies bonus…
Step by step
Solved in 3 steps with 1 images
- (Misc. application) a. Write a program to reverse the digits of a positive integer number. For example, if the number 8735 is entered, the number displayed should be 5378. (Hint: Use a do statement and continuously strip off and display the number’s units digit. If the variable numinitially contains the number entered, the units digit is obtained as (num % 10). After a units digit is displayed, dividing the number by 10 sets up the number for the next iteration. Therefore, (873510)is5and(8735/10)is873. The do statement should continue as long as the remaining number is not 0.) b. Run the program written in Exercise 3a and verify the program by using appropriate test data.09. FizzBuzz problem:- Write a program which return "fizz" if the number is a multiplier of 3, return "buzz" if its multiplier of 5 and return "fizzbuzz" if the number is divisible by both 3 and 5. If the number is not divisible by either 3 or 5 then it should just return the number itself?.17. Math Tutor Write a program that can be used as a math tutor for a young student. The program should display two random numbers to be added, such as 247 +129 The program should then pause while the student works on the problem. When the student is ready to check the answer, he or she can press a key and the program will display the correct solution: 247 +129 376
- Challenge Problem (pyhton) T E S T S C O R E S Write a program that implements a test scores program. Valid test score entries are between 0 and 100 inclusive. The program should display a welcome message and run everything through the "main" function. have the ability to enter several test scores (try a loop) and print out the total score, as well as, the average score. continuously ask for test scores until the number 99.9 has been entered. test for valid entries and the value 99.9. If a test score is valid, the program should add the current score to the total score and update the number of test scores by one (+1), otherwise it displays an error message. Note : This assignment involves the use of a while loop and if-else decision making controls. You CANNOT use the reserved keywords break and continue for any portion of this program or any program for that matter throughout this course.Q1: b- Write a program that uses a switch statement to determine if the number is odd or even for the range of numbers from 1 to 10.Exercise I- Medicine Write a program that asks the user to enter the name of the medicine (t for ThroX, f for FeliX), his mass. The user should enter as well if he has a prescription or not. The program will calculate the dosage using: age and his ThroX without prescription -The max dosage should be 0.75 mL -The dosage = mass / 150 -The number of pills per day to take is 1 ThroX with prescription -The dosage =mass * 3 / 150 -The number of pills per day to take is 5 FeliX with prescription -The dosage = 0.77 mL FeliX without prescription -The dosage should be between 0.3 and 0.7 -The dosage = mass * 0.009 -The number of pills per day to take is 2 -The number of pills per day to take is 6 The program should display the dosage and the number of pills to be taken per day if the requirements are full filled, otherwise it display "Please check your doctor for a prescription". In case the medicine does not exist in the database, the program display “Your medicine is not in our database!"…
- C++ Programming: Instructions The program in Example 5-6 implements the Number Guessing Game. However, in that program, the user is given as many tries as needed to guess the correct number. Rewrite the program so that the user has no more than five tries to guess the correct number. Your program should print an appropriate message, such as “You win!” or “You lose!”. Code Given: //Flag-controlled while loop. //Number guessing game. #include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main() { int num; //variable to store the random number int guess; //variable to store the number guessed by the user bool isGuessed; //boolean variable to control the loop srand(time(0)); num = rand() % 100; isGuessed = false; while (!isGuessed) { cout << "Enter an integer greater" <<" than or equal to 0 and " <<"less than 100: "; cin >> guess; cout << endl; if (guess == num) { cout << "You win! " <<…Q7-Write a program that simulates a simple calculator. It reads two integers and a character. If the character is a +, the sum is printed; if it is a -, the difference is printed; if it is a *, the product is printed; if it is a /, the quotient is printed; and if it is a %, the remainder is printed. (Use a switch statement.)Time CalculatorWrite a program that asks the user to enter a number of seconds.-There are 60 seconds in a minute. If the number of seconds entered by the user is greater than or equal to 60, the program should display the number of minutes and leftover seconds in that many seconds.-There are 3,600 seconds in an hour. If the number of seconds entered by the user is greater than or equal to 3,600, the program should display the number of hours, minutes, and leftover seconds in that many seconds.-There are 86,400 seconds in a day. If the number of seconds entered by the user is greater than or equal to 86,400, the program should display the number of days, hours, minutes, and leftover seconds in that many seconds.
- use C++ programming language Write a program that computes and displays the charges for a patient’s hospital stay. First, the program should ask if the patient was admitted as an inpatient or an outpatient. If the patient was an inpatient, the following data should be entered: The number of days spent in the hospital The daily rate Charges for hospital services (lab tests, etc.) Hospital medication charges If the patient was an outpatient, the following data should be entered: Charges for hospital services (lab tests, etc.) Hospital medication charges Use a single, separate function to validate that no input is less than zero. If it is, it should be reentered before being returned. Once the required data has been input and validated, the program should use two overloaded functions to calculate the total charges. One of the functions should accept arguments for the inpatient data, while the other function accepts arguments for outpatient data. Both functions should return the…/*random number guessing game with while loopscreate a program (or adapt the guessing game program that's posted in moodlea couple of weeks ago) that asks the user to guess a random number between one and sixteen,and compares their guess with the computer's number.save this program as guessLoops.cppThe program should display one of four messages:if your guess is higher than the computer's number: "Your guess is too high."if your guess is lower than the computer's number: "Your guess is too low."if your guess is the same as the computer's number: "That is correct!"if your guess is less than one or greater than sixteen: "Invalid guess."If it's the last one, invalid guess, prompt the user, by using a loop, to guess again.If your guess is too high or too low, ask the user if they'd like to guess again (if theanswer is 'y' for yes, repeat the statements that asks for a guess.Then, repeat statement on line #6-#9 above.If the answer is 'n' for no (meaning the user doesn't want to guess…Problem definition: A college wants to know how well its students did on an exam. The following program summarizes the results. The program asks a user to enter the results pass (1) or fail (2) for 10 students. It displays the number of passed and the number of failed. It displays a message "Raise error" if the number of passes is more than 8 You are asked to identify statement with syntax errors by selecting them as wrong and the correct statements as right