Rewrite the following expressions as C++ assignment statements that use the conditional operator. (Assume that all variables are declared properly.) //a. if (x > y) z = x - y; else z = y - x; //b. if (hours >= 40.0) pay = 40 * 7.50 + 1.5 * 7.5 * (hours - 40); else pay = hours * 7.50; //c. if (points >= 60) str = "Pass"; else str = "Fail";
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: Write an if statement that assigns 0.4 to commission if sales is greater than or equal to 10000. In…
A: Write an if statement that assigns 0.4 to commission if sales is greater than or equal to 10000.…
Q: Write a if-elif-else statement that distinguishes between a negative number or 0, a number between 0…
A: The elif is also known as else if. The elif is allows us to check for multiple expressions.
Q: Chargeable Income (RM) Calculation (RM) Rate '% tax(rm) 0 — 5,000 On the First 5,000 0 0…
A: Introduction of the Program: The C program takes a user name and user's chargeable income from the…
Q: Write an if statement that increases pay by 3% if score is greater than 90, otherwise increases pay…
A: if(condition){ statement; ...}else{ statements; ...}
Q: Using C++ program 1. ( Use if-else statement ) Write a program for asking for a quiz score. The…
A: C++ program to solve the given problem is below.
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: In C++ program Kindly convert the structure of the program from "if else if" statement to "switch"…
A: I have provided C++ CODE along with OUTPUT SCREENSHOT----------------
Q: If money is left in a particular bank for more than 5 years, the bank pays interest at a rate 4.5%;…
A: PROGRAM CODE: #include <iostream> using namespace std; int main(){ int numYears,money;…
Q: Using C++ programming language: 01. Write a simple if statement that multiplies the variable num1…
A: As per company rules we are only supposed to answer only one question kindly post another question…
Q: Write a program in C++ that displays the following checkerboard pattern. Your program must use only…
A: The answer is...
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: Write a C++ program. A software company sells a package that retails for $109. Quantity discounts…
A: To write a C++ program using the if/else if/else statement that asks for the number of units sold…
Q: Question #4: Use for statement to write a C program that asks the user to enter a positive integer…
A: required:
Q: The unit for electricity usage is kWh. For domestic usage, the monthly rate is 200 baisa/unit for…
A: The answer is given bwlow:-
Q: 1. Write a program that prints "You have passed" if a student gets a score of 50 and above, and…
A: QUESTION 1 PART 1 import java.util.*;public class HelloWorld{public static void main(String…
Q: Time left 047:29 Write a complete C++ program that prompts the user to enter a string, and prints…
A: start input string using if else print appropriate statement stop
Q: The table below shows the AZA Travel Tour ticketing price: Package b) c) d) Istanbul Beijing Tokyo…
A: Step 1: Start Step 2: take input of package code Step 3: validate package code if valid continue…
Q: If money is left in a particular bank for more than 5 years, the bank pays interest at a rate of…
A: CODE:- #include <iostream>using namespace std;void check(int numYears){ if (numYears >…
Q: Questlon Two: Write a C+ program to calculate the average of five student grades, then print "A+" if…
A: Output 1: Output 2: Output 3: Output 4:
Q: Mars hyper market gives discount to customers based on their spending. If a customer spends 20 Omani…
A: #include<iostream>using namespace std;int main(){ float spending; cin>>spending;…
Q: In C++ (Find the number of days in a month) Write a program that prompts the user to enter the…
A: Answer: This is my answer: But the complier reported: 1. Compiler error : fatal error 2. #include 3.…
Q: Rewrite the following expressions using an if. . .else statement in C++. (Assume that all variables…
A: 1. Program: #include <iostream> using namespace std; int main() { int overSpeed, fine;…
Q: What is the output of the following statements? a. if ('+' < '-')cout << "+-";cout <<…
A: a) b)
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: this is c program Write program that ask the user to enter int mark (0-100) for test Physics. Then…
A: Your C program is given below as you required with an output.
Q: You can have more than one nested else-if in C program. O True O False A switch statement can have…
A: Given: 3Please answer the tree questions!
Q: In C, the condition that will give a true statement when a number x is in the range of is 0 10 O x>0…
A:
Q: ACE balloon shop sells balloons to customers at 10 Fils each. If the customer buys 500-1000…
A: As per the requirement program is completed in c++. Algorithm: Step 1: Write the main() method Step…
Q: The table below shows the Package Istanbul Beijing Tokyo b) c) d) Pavel Tour ticketing price:…
A: Code : #include<iostream>using namespace std;int main(){ double totalPrice=0;…
Q: Q2. Use ? operator to write C++ program to find the value of the variable G if you know that.(do not…
A: // Code #include <iostream>#include <math.h> using namespace std; int main(){ int…
Q: A) Use (switch statement) to write a program in C++ to show company structure. I r is (A), print…
A: Here we need to use switch case on some character input. The syntax for switch case is…
Q: Time left 0:47:29 Write a complete C++ program that prompts the user to enter a string, and prints…
A: Algorithm: Start Read a string s Store length of string s in n If n>=0 and n<=3, then print…
Q: Rewrite the following C program using if-else statements. #include int main(void){ int…
A: PROGRAM CODE: #include<stdio.h> // include header file for standard input output int…
Q: Write an if statement that assigns 0.2 to commission if sales is greater than or equal to 10000. In…
A: Step 1: Prompt and accept the sale amount from the user. Step 2: Check whether the sale amount is…
Q: a. Write C11 statements that output First Year if the standing is 'F', Sophomore if the standing is…
A: if (standing == 'F') printf ("First Year"); else if (standing == 'S') printf…
Q: If money is left in a particular bank for more than 5 years, the bank pays interest at a rate of…
A: PROGRAM CODE: #include <iostream> // include header file for input output streamusing…
Q: If-else statements: Write a C++ program for an ATM to dispense bills against a requested amount.…
A: PROGRAM CODE: #include <iostream> // include header file for input output…
Q: Convert the following C++ code from if-Statement to switch-statement, such that it gives the same…
A: Define header file <iostream> for io operations. Define main function. Define int variable x.…
Q: A. Write C ++ statements that output First Year if the standing is 'F', Sophomore if the standing is…
A: A. C++ code #include <iostream> using namespace std; int main() { char choice; cout…
Q: turbo c++ program of You have a choice of 2 different auto mechanics with different rate…
A: As you have mentioned C++ program of the question, only program is written. The program is written…
Q: Using conditional statements, create a C++ program that will ask the user's height and weight then…
A: Introduction: The formula for BMI is shown below. BMI=Weight in kg(Height in meters)2…
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: In conditional statements, the result of the condition is checked for _________________.
A: We need to fill the given statement such that the statement is complete and true. Given statement is…
Q: Can you rewrite the following C++ code using the Switch statement instead of the If statement? int…
A: Here, I have to choose an option for the above question.
Q: e a statement using a conditional operator to do the following: if x is less…
A: 1. conditional operator in c int x,y,z; z = (x<y)? 20 : 0; Explanation if(x<y) { z=20; } else…
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) >…
Rewrite the following expressions as C++ assignment statements that use the conditional operator. (Assume that all variables are declared properly.)
//a.
if (x > y)
z = x - y;
else
z = y - x;
//b.
if (hours >= 40.0)
pay = 40 * 7.50 + 1.5 * 7.5 * (hours - 40);
else
pay = hours * 7.50;
//c.
if (points >= 60)
str = "Pass";
else
str = "Fail";
The syntax of the conditional operator is as follows:
Expression1 ? Expression2 : Expression3
If Expression1 is true, then Expression2 is evaluated else Expression3 is evaluated.
a. Write the assignment statement for given statements as follows:
z = ( x>y ? x-y : y-x);
Trending now
This is a popular solution!
Step by step
Solved in 3 steps
- C ++ Code Write a program that can be used to calculate the federal tax. The tax is calculated as follows: For single people, the standard exemption is $4,000; for married people, the standard exemption is $7,000. A person can also put up to 6% of his or her gross income in a pension plan. The tax rates are as follows: If the taxable income is: Between $0 and $15,000, the tax rate is 15%. Between $15,001 and $40,000, the tax is $2,250 plus 25% of the taxable income over $15,000. Over $40,000, the tax is $8,460 plus 35% of the taxable income over $40,000. Prompt the user to enter the following information: Marital status If the marital status is “married,” ask for the number of children under the age of 14 Gross salary (If the marital status is “married” and both spouses have income, enter the combined salary.) Percentage of gross income contributed to a pension fund Your program must consist of at least the following functions: Function getData: This function asks the user to enter…Complete C++ statements to carry out the following tasks. Assume the following variable has been declared. 1) Make x to be the reverse of all the odd digits of original x (ie, x is 23451 originally, x then becomes 153. tempRev temperately store the reverse number). Assume x is a positive number, if x is negative it may do anything. int x, tempRev = 0; ){ tempRev 7 tempRev;A salon offers coupons to its customers time to time. Without coupons adult haircut is 15.50 and the child haircut is 10.50. Coupons that this salon offers are color coded. The following table shows the color code and discount information Color code Green (code # 1) Blue (code # 2) Discount 3.50 from adult, 2.50 from kids 2.59 from adult, 1.50 from kids Write a C++ program that asks the user to enter the coupon color and the haircut type (adult, kid) and then determine the haircut charge. It is possible that a customers may not have a coupon, in that case, no discount will be offered. You can assume that green, blue colors are represented using 1 and 2 respectively. Write the program so it will generate the output as shown in the sample runs below where user input is in bold. Sample Run 1 Enter coupon color (0 = no coupon, 1 = green, 2 = blue): 1 Enter the type of haircut (a= adult or k = kid): a The charge is 12.00 Sample Run 2 Enter coupon color (0= no coupon, 1 = green, 2 = blue): 0…
- 3 points Save Answer 1. Write C++ statement(s) to check If the difference between volt 1 and volt 2 is larger than 10.0, print the values of volt 1, if volt 2 is larger than 20 then print volt 2 otherwise print volt 1.Using c++ 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 total chargesInternet Service provider An Internet service provider has three different subscription packages for its customers: Package A: For $9.95 per month 10 hours of access are provided. Additional hours are $2.00 per hour. Package B: For $13.95 per month 20 hours of access are provided. Additional hours are $1.00 per hour. Package C: For $19.95 per month unlimited access is provided. Write a program using c++ that calculates a customer's monthly bill. It should ask the user to enter the letter of the package the customer has purchased (A, B, or C) and the number of hours that were used. It should then display the total charges.
- CODE USING C++ Problem: Create a program that will let the user input his/her name and gender. If the user is male, prompt the user to choose team: Jaguar, Eagle or Crocodile. If the user is female, prompt the user to choose team: Barbie, Prada, Payless. The output should display in a sentence form the name and the selected team of the user. Expected Sample Output: Enter Name: DarylEnter Sex: FemaleChoose your team (Barbie, Prada or Payless): barbieYour name is Daryl and you choose to be in Team Barbie.Assuming X1,X2, Y1 are integer type variables, A,B,C are Bool type variables and Z as real type variable. Check the wrong statements Y1:=(X1 AND X2) +2; if A:=True Then B:=False; End_if; If Z>10 Then Y1:=X1 +4; End_if; C:=(A AND B ) +1; For Z:=1 to 10 Do Y1:=Y1 +1; End_For; While (AB) Do Y1:=Y1+1; End_While;Question 1 Write a c program that allows to calculate z = |x-yl with x, y, z declared as integer and x and y initialized with values of your choice. Use for that a conditional structure: if .....; else ........; Type your answer Question 2 -- / 0 Type your answer -- / 0 Write a c program that allows to calculate z = |x-y| with x, y, z declared as integer and x and y initialized with values of your choice. Use for that a conditional structure: z = (condition)?(result1):(result2);
- C++ Write a program that asks for the starting time and the number of minutes of the call, and displays the charges. The program should ask for the time to be entered as a floating-point number in the form HH.MM. For example, 07:00 hours will be entered as 07.00, and 16:28 hours will be entered as 16.28. Input Validation The program should not accept times that are greater than 23:59. Also, no number whose last two digits are greater than 59 should be accepted. Hint: Assuming num is a floating-point variable, the following expression will give you its fractional part: num – static_cast<int>(num);c++ Total Purchase A customer in a store is purchasing five items. The prices of the five items are: price of item 1 = $15.95 price of item 2 = $24.95 price of item 3 = $6.95 price of item 4 = $12.95 price of item 5 = $3.95 Write a program that holds the prices of the five items in five variables. Display each item’s price, the subtotal of the sale (total price of five items without tax), the amount of sales tax, the total. Assume the sales tax is 7%, define it as a named constant in your program.Using c++ write a program : Write a program in C++ to handle the following scenario: Three friends Asif, Shahid and Bashir start the business. Input following from user. Enter amount invested by Asif (user will enter any value) Bashir’s contribution is equal to 250% of Asif’s contribution and Shahid’s contribution is equal to 75% of Bashir’s contribution. Display amount contributed by Bashir and Shahid. After 6 months business earned profit of 50% of total investment. Display the total profit and the amount each sharer will get (i.e. distribute profit as per percentage of their investment).