Concept explainers
Write one or more C++ statements that assign the correct value to discount, using the logic described here:
Assign .20 to discount if dept equals 5 and price is $100 or more.
Assign .15 to discount if dept is anything else and price is $100 or more.
Assign .10 to discount if dept equals 5 and price is less than $100.
Assign .05 to discount if dept is anything else and price is less than $100.
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
MyLab Programming with Pearson eText -- Standalone Access Card -- for Starting Out With C++: Early Objects (My Programming Lab)
Additional Engineering Textbook Solutions
Starting out with Visual C# (4th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
C Programming Language
Introduction To Programming Using Visual Basic (11th Edition)
Problem Solving with C++ (10th Edition)
C++ How to Program (10th Edition)
- (Data processing) Years that are evenly divisible by 400 or are evenly divisible by 4 but not by 100 are leap years. For example, because 1600 is evenly divisible by 400, 1600 was a leap year. Similarly, because 1988 is evenly divisible by 4 but not by 100, it was also a leap year. Using this information, write a C++ program that accepts the year as user input, determines whether the year is a leap year, and displays a message telling the user whether the entered year is or is not a leap year.arrow_forwardIn C++, write a program that prompts the user to input three numbers. The program should then output the numbers in ascending order using a combination of if-else statements.arrow_forwardQ1) How 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 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.arrow_forward
- 66. Write a C program using control statements if-else to read the score of a student from 0 to 100 and print the result accordingly. Score>80: Passed and promoted. 40<Score<=80: Passed. Score<=40: Fail and demoted.arrow_forward(C PROGRAMMING ONLY) 6. Deal or No Deal?by CodeChum Admin When I was a kid, I used to watch this TV game show, Deal or No Deal? In the game, there are different brief cases, each labeled with a number. Inside each brief case is an amount in Pesos and the goal is to guess which briefcase contains the smallest amount. In this program, instead of just finding the smallest amount, your task is to ask the user for an integer input and print the values in the array smaller than the inputted integer. Instructions: In the code editor, you are provided with an array with 100 elements.Your task is to ask the user for an integer input and then print all the elements in the array whose value is lesser than the inputted integer.Input 1. Inputted integer Output Enter value: 6132450351503022244arrow_forwardIn C++ Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as input, and output the gas cost for 20 miles, 75 miles, and 500 miles. Output each floating-point value with two digits after the decimal point, which can be achieved by executingcout << fixed << setprecision(2); once before all other cout statements. Ex: If the input is: 20.0 3.1599 the output is: 3.16 11.85 79.00 Note: Real per-mile cost would also include maintenance and depreciation.arrow_forward
- Write a C++ statement that uses the manipulator setfill to output a line containing 35 stars, as in the following line: ***********************************arrow_forwardC++ Programming Exercise: 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 that prompts the user to enter: a. The total number of of units. b. The rent to occupy all the units. c. The increase in rent that results in a vacant unit. d. Amount to maintain a rented unit. The program then outputs the number of units to be rented to maximize the profit.arrow_forwarda. Write C11 statements that output First Year if the standing is 'F', Sophomore if the standing is 'S', and Junior or Senior otherwise. b. Write C11 statements that output First Year or Sophomore if the standing is '1' or '2', Junior or Senior if the standing is '3' or '4', and Graduate Student otherwise.arrow_forward
- 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…arrow_forwardIn C#, falling through a switch case is most often prevented by using the ________ statement• a. end• b. break • C. case• d. defaultarrow_forwardIn C Declare a variable of type double.Ask the user for a value and place it in the declared variable.Write code to check for and output statement stating whether the variable is zero, positive, ornegative.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr