Question: (C++ coding assignment) You may assume that the variables named answer, speed, and year have all been declared as integer (int) variables. You may also
(C++ coding assignment)
- You may assume that the variables named answer, speed, and year have all been declared as integer (int) variables. You may also assume that the variable named year has been assigned an integer (int) value. Compose a complete if statement that assigns the value 42 to the variable named answer and assigns the value 65 to the variable named speed if the value of the variable named year is greater than 2121.
- Compose an if statement that assigns 0 to the variable benefit and assigns 1 to the variable cost if the variable age is less than 49.
- Compose an if-else statement that assigns 0 to the variable boost if the variable tone is less than 10, otherwise, it should assign 79 to the variable boost.
- Write an if-else-if statement that assigns Platinum, Gold, or Silver to a string variable named status depending on the value in a double variable named donation. Platinum status is awarded for donations over $10,000. Gold status is awarded for donations that are not more than $10,000 but are at least $5,000. Silver status is awarded for donations that are less than $5,000. You may assume that the variable named status has been declared as a string data type and that the variable named donation has been declared as a double data type and has been initialized to a value that is greater than zero.
- Assume that the variables named a, b, c, and result have all been declared as integer (int) variables and assigned values. Convert the following code to a single C++ statement that uses the conditional operator:
if (a <= b) result = c + 2; else result = c - b;
Answers must be in C++
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
