STARTING OUT WITH C++ MPL
9th Edition
ISBN: 9780136673989
Author: GADDIS
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 3, Problem 11RQE
Explanation of Solution
Program code:
The given statement and defined variables are combined to form a complete source code:
// Include the required header files
#include <iostream>
using namespace std;
// Main function
int main()
{
//Declare integer type variables
int a, b = 2;
//Declare float variable
float c = 4.3;
/* Perform multiplication using a float and an integer type values store the resultant value in variable "a" */
a = b*c;
//Display "a" value
cout << a<<endl;
// Return statement
return 0;
}
...Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Assume a program has the following variable definitions
int a, b = 2; double c = 4.3;and the following statement:a = b * c;What value will be stored in a?
Needs to be done in C# language.
Problem
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 in-patient or an out-patient. If the patient was an in-patient, the following data should be entered:
• The number of days spent in the hospital• The daily rate• Hospital medication charges• Charges for hospital services (lab tests, etc.)
The program should ask for the following data if the patient was an out-patient:
• Charges for hospital services (lab tests, etc.)• Hospital medication charges
The program should use two overloaded functions to calculate the total charges. One of the functions should accept arguments for the in-patient data, while the other function accepts arguments for out-patient information. Both functions should return the total charges.
Input Validation: Do not accept negative numbers for any data.
Assume a program has the following variable definitions
int units; float mass; double weight;and the following statement:weight = mass * units;Which automatic data type conversions will take place?
Chapter 3 Solutions
STARTING OUT WITH C++ MPL
Ch. 3.1 - Prob. 3.1CPCh. 3.1 - What is the symbol called?Ch. 3.1 - Where does cin read its input from?Ch. 3.1 - Prob. 3.4CPCh. 3.1 - Assume value is an integer variable. If the user...Ch. 3.1 - A program has the following variable definitions....Ch. 3.1 - The following program will run, but the user will...Ch. 3.1 - Complete the following main function so that it...Ch. 3.2 - In each of the following cases, tell which...Ch. 3.2 - Complete the following table by writing the value...
Ch. 3.2 - Prob. 3.11CPCh. 3.2 - Study the following program code and then complete...Ch. 3.2 - Complete the following program skeleton so that it...Ch. 3.3 - Assume the following variable definitions: int a =...Ch. 3.3 - What will the following program code display if a...Ch. 3.3 - What will the following program code display? int...Ch. 3.5 - Prob. 3.17CPCh. 3.5 - Complete the following program code segment so...Ch. 3.6 - Write a multiple assignment statement that assigns...Ch. 3.6 - Write statements using combined assignment...Ch. 3.6 - What will the following program segment display?...Ch. 3.7 - Write cout statements with stream manipulators...Ch. 3.7 - The following program segment converts an angle in...Ch. 3.8 - Will the following string literal fit in the space...Ch. 3.8 - If a program contains the definition string name;...Ch. 3.8 - Prob. 3.26CPCh. 3.10 - Use a mathematical library function with a cout...Ch. 3.10 - Assume the variables angle1 and angle2 hold angles...Ch. 3.10 - To find the cube root (the third root) of a...Ch. 3.10 - Write a statement that produces a random number...Ch. 3 - Prob. 1RQECh. 3 - Prob. 2RQECh. 3 - Prob. 3RQECh. 3 - Assume the following variables are defined: int...Ch. 3 - What header files must be included in the...Ch. 3 - Prob. 6RQECh. 3 - Prob. 7RQECh. 3 - Complete the following table. Expression Value of...Ch. 3 - Write C++ expressions for the following algebraic...Ch. 3 - Assume a program has the following variable...Ch. 3 - Prob. 11RQECh. 3 - Assume that qty and salesReps are both integers....Ch. 3 - Rewrite the following variable definition so the...Ch. 3 - Complete the following table by writing statements...Ch. 3 - Write a multiple assignment statement that can be...Ch. 3 - Write a pair of multiple assignment statements...Ch. 3 - Replace the following statements with a single...Ch. 3 - Is the following code legal? Why or why not? const...Ch. 3 - Write a cout statement that uses stream...Ch. 3 - Write a cout statement that uses stream...Ch. 3 - What header file must be included A) to perform...Ch. 3 - Pet World offers a 15 percent discount to senior...Ch. 3 - A bowling alley is offering a prize to the bowler...Ch. 3 - A retail store grants its customers a maximum...Ch. 3 - Little Italy Pizza charges 14.95 for a 12-inch...Ch. 3 - Trace the following program segments and tell what...Ch. 3 - A) (Assume the user enters George Washington.)...Ch. 3 - Each of the following program segments has some...Ch. 3 - A) const int number1, number2, product; cout ...Ch. 3 - Soft Skills Often programmers work in teams with...Ch. 3 - Miles per Gallon Write a program that calculates a...Ch. 3 - Stadium Seating There are three searing categories...Ch. 3 - Housing Costs Write a program that asks the user...Ch. 3 - How Much Insurance? Many financial experts advise...Ch. 3 - Batting Average Write a program to find a baseball...Ch. 3 - Test Average Write a program that asks for five...Ch. 3 - Average Rainfall Write a program that calculates...Ch. 3 - Male and Female Percentages Write a program that...Ch. 3 - Vacation Days Write a program that prompts the...Ch. 3 - Box Office A movie theater only keeps 80 percent...Ch. 3 - How Many Widgets? The Yukon Widget Company...Ch. 3 - How many Calories? A bag of cookies holds 30...Ch. 3 - Ingredients Adjuster A cookie recipe calls for the...Ch. 3 - Celsius to Fahrenheit Write a program that...Ch. 3 - Currency Write a program that will convert U.S....Ch. 3 - Monthly Sales Tax A retail company muse file a...Ch. 3 - Property Tax Madison County collects property...Ch. 3 - Senior Citizen Property Tax Madison County...Ch. 3 - Math Tutor Write a program that can be used as a...Ch. 3 - Interest Earned Assuming there are no deposits...Ch. 3 - Monthly Payments The monthly payment on a loan may...Ch. 3 - Pizza Slices Joe's Pizza Palace needs a program to...Ch. 3 - How Many Pizzas? Modify the program you wrote in...Ch. 3 - Angle Calculator Write a program that asks the...Ch. 3 - Stock Transaction Program Last month Joe purchased...
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Assume the following variables are defined: char ch; double interest ; string name ; Assign each variable to a value of the correct data type.arrow_forwardA program contains the following function. int cube(int num) {return num * num * num; }Write a statement that passes the value 4 to this function and assigns its return value to the variable result.arrow_forwardThe Problem__: Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions: ⚫ void getScore() should ask the user for a test score, store it in a reference param- eter variable, and validate it. This function should be called by main once for each of the five scores to be entered. ⚫ void calcAverage() should calculate and display the average of the four highest scores. This function should be called just once by main and should be passed the five scores. ⚫int findLowest() should find and return the lowest of the five scores passed to it. It should be called by calcAverage, which uses the function to determine which of the five scores to drop. Input Validation: Do not accept test scores lower than 0 or higher than 100. YOU MUST USE THE STATED FUNCTIONS AND COMPLETE Input VALIDATION. **DO NOT use an ARRAY OR GLOBAL VARIABLES!!. you MUST USE function prototyping TEST THE FUNCTION TWICE.…arrow_forward
- HUK computer store offers credit plan at 10% down payment and an annual interest rate of 12%. You are required to write a C++ program to calculate and print the payment schedule for a loan to purchase a computer for the first month: a. Prompt the user for the purchase b. Write a void function called display() to print the following headings: The month number The starting balance The interest to pay The principal to pay The monthly payment The ending balance for that month c. Create a double function called creditcredit() that has the purchase price as its parameter. The function must do the following (d to j): d. Create two variables annual interest rate = 12% monthly rate = annual interest rate/12 e. The month number should begin with 1 f. Use a loop to display information for 12 months g. Monthly payment is calculated at 5% of the purchase h. The amount of interest for a month is calculated as the…arrow_forwardC programarrow_forwardin c++ Write a program to generate a random number between 1 - 100, and then display which quartile the number falls in. First quartile is 1 - 25 Second quartile is 26 - 50 Third quartile is 51 - 75 Fourth quartile is 76 - 100 To generate a random number, follow these steps: include necessary header files #include <cstdlib> //for random functions #include <ctime> //for time functions set constants for the minimum and maximum values of the desired range const int MIN_VALUE = 1; //minimum range value const int MAX_VALUE = 100; //maximum range value seed the random number generator (RNG) with a unique unsigned int value - system time! unsigned seed = time(0); //system time in seconds since 1/1/1970 srand(seed); //seed the RNG get a random number in the desired range int num = (rand() % (MAX_VALUE - MIN_VALUE + 1)) + MIN_VALUE; The program should: contain header comments as shown in class display a "hello" message (more descriptive than shown in sample)…arrow_forward
- C++ beginnerarrow_forwardC++ Visual 2019 A particular talent competition has five judges, each of whom awards a score between 0 and 10 to each performer. Fractional scores, such as 8.3, are allowed. A performer's final score is determined by dropping the highest and lowest score received, then averaging the three remaining scores. Write a program that uses this method to calculate a contestant's score. It should include the following functions: void getJudgeData() should ask the user for a judge's score, store it in a reference parameter variable, and validate it. This function should be called by main once for each of the five judges. void calcScore() should calculate and display the average of the three scores that remain after dropping the highest and lowest scores the performer received. This function should be called just once by main and should be passed the five scores. The last two functions, described below, should be called by calcScore, which uses the returned information to determine which of the…arrow_forwardi uploaded the screenshot please help me to do pseudocode And do flowchart should be in c++arrow_forward
- Q/In C++, the following expression is an expression "a='x' || b='y' " logical expression arithmetic expression O figurative expression The expression is incorrectarrow_forwardc++ Write a function that returns a float value. The function will check the users entry. It will return a float value which is between 0 and 100 and is divisible by 17 If entered value is not a float, display “Error!!! Not a number”. If the number is out of range display “Error!!! Outside the range”. If the number is not between the range, the users will be prompted to enter another number. It will return only a valid numberarrow_forwardwrite the definition statement for a variable fltPtr. The variable should be a pointer to a floatarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning