STARTING OUT WITH C++ MPL
9th Edition
ISBN: 9780136673989
Author: GADDIS
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 3, Problem 21RQE
What header file must be included
A) to perform mathematical functions like sqrt ?
B) to use cin and cout?
C) to use stream manipluators like setprecision?
D) to use random numbers?
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
In C++
Create a function called SuperRandomNumber. It should accept a number called top as the argument. It should output to a file 100 random numbers below top.
Problem Definition
Task. Your task is to develop a python program that reads input from text file and finds if the
alphanumeric sequence in each line of the provided input file is valid for Omani car license plate.
The rules for valid sequences for car plates in Oman are as follows:
Each sequence is composed of 1 to 5 digits followed by one or two letters.
Digits cannot start with 0, for instance, 00, 011, or 09 are not valid digit sequences.
The following list are the only valid letter combinations:
['A','AA','AB','AD','AR','AM','AW",'AY"',
'B', BA','BB','BD',"BR','BM',"BW',"BY',
'D','DA','DD','DR','DW','DY',
'R','RA','RR','RM','RW','RY',
'S','SS',
'M','MA','MB','MM','MW','MY",
"W',"WA',WB',"wW',
Y,YA','YB','YD','YR','YW',YY]
Program Input/Output. Your program should read input from a file named plates.txt and write
lines with valid sequences to a file named valid.txt. Any line from the input file containing invalid
sequence should be written to a file named invalid.txt. Each line…
Common Time Zones
Function Name: commonTimeZones()
Parameters: code1( str ), code2( str)
Returns: list of common time zones ( list )
Description: You and your friend live in different countries, but you figure there's a chance that
both of you might be in the same time zone. Thus, you want to find out the list of possible time
zones that you and your friend could both be in. Given two country codes, write a function that
returns a list of the time zones the two countries have in common. Be sure not to include any
duplicate time zones. If the two country codes do not have any common time zones, return the
string 'No Common Time Zones' instead.
Note: You can assume that the codes will always be valid.
example test cases:
>>> commonTimeZones('can', 'usa')
[UTC-08:00', 'UTC-07:00', 'UTC-06:00', 'UTC-05:00', 'UTC-04:00]
>>> commonTimeZones('rus', 'chn')
[UTC+08:00]
For this assignment, use the REST countries API
(https://restcountries.com/#api-endpoints-v2).
For all of your requests, make…
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...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Run the hello, world program on your system. Experiment with leaving out parts of the program, to see what erro...
C Programming Language
Using an example of a component that implements an abstract data type such as a stack or a list, show why it is...
Software Engineering (10th Edition)
What is the highest decimal number that can be represented by each of the following numbers of binary digits (b...
Digital Fundamentals (11th Edition)
Personal Information Class Design a class that holds the following personal data: name, address, age, and phone...
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
What is the distinction between application software and system software? Give an example of each.
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
The startsWith, endsWith, and regionMatches methods are members of this class. a. String b. Char c. Character d...
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
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
- Common Time Zones Function Name: commonTimeZones() Parameters: code1( str ) , code2( str ) Returns: list of common time zones ( list ) Description: You and your friend live in different countries, but you figure there's a chance that both of you might be in the same time zone. Thus, you want to find out the list of possible time zones that you and your friend could both be in. Given two country codes, write a function that returns a list of the time zones the two countries have in common. Be sure not to include any duplicate time zones. If the two country codes do not have any common time zones, return the string 'No Common Time Zones' instead. Note: You can assume that the codes will always be valid. example test cases: >>> commonTimeZones('can', 'usa') ['UTC-08:00', 'UTC-07:00', 'UTC-06:00', 'UTC-05:00', 'UTC-04:00'] >>> commonTimeZones('rus', 'chn') ['UTC+08:00'] For this assignment, use the REST countries API…arrow_forwardPlease explain in C++arrow_forwardBody Mass Index Write a program that reads names, weights, and heights from bmi.dat (provided with starter code; do not change the file name). Use the information to calculate and displays a person’s body mass index (BMI). The BMI is often used to determine whether a person with a sedentary lifestyle is overweight or underweight for his or her height. A person’s BMI is calculated with the following formula: BMI = weight × 703 / height2 where weight is measured in pounds and height is measured in inches. The file is in the format name weightInKG heightInCM You will read the name, weight and height for 4 people from the file, and you will need to convert the weights in the file to pounds (note that 1 kilogram = 2.2 pounds) and the heights to inches (2.54 cm = 1 inch). The program should display the person's name along with the calculated BMI and a message indicating whether the person has optimal weight, is underweight, or is overweight. Your output should look like A person’s weight…arrow_forward
- Please write C++ code for the following. Please show all source code. Thank you. Write a C++ program that interacts with a text file that contains a list of student IDs and their corresponding grades for their test. The program will import the file contents into the program, separate the IDs and their grades, and then sort the students based on their grade in descending order. The program will then display the top 10 scores, as well as the names of the students who earned those scores. You will make a class called Student. This class will have three attributes, one that stores their name, one that stores their grade, and one that stores a unique ID number. Additionally, there will be setters and getters for each of the attributes, where the setter for “grade” should ensure that the grade is valid (i.e., between 0 and 100). In addition to the setters and getters, you will overload the relational operators (i.e., ==, < > <= >= !=) in order to make student objects…arrow_forwardplease code in pythonRead in and return a list of review dates. The function should ask the user to enter some review dates This should be entered in the format mm/dd/yyyy (same as that in the file) where dd is two-digit day, mm is two digit month and yyyy is a four digit year e.g. 01/22/2020 The function should return a list containing the specified review dates. :return: a list of review datesYou can take any review date as sample examplearrow_forwardc++ programming languagearrow_forward
- Average grades bar chart Write a python program grades.py that reads a file of assignment grades and draws a bar chart of the average grades for each assignment. Save the figure as grades.png in the current working directory. The format of a line in the file is: assignment_type grade Note that there is a single space between the assignment type and the grade. E.g. exam 92.80 Your program must contain the following functions: Function name Function description Function input(s) Function return value(s) get_grades() This function takes a file name as input and populates a dictionary containing the assignment types and grades. Filename string Dictionary of grades main() This function prompts for the grades file name. Next, it calls the functions get_grades(). Next, it draws the bar chart of the average grade for each assignment. Hint: You can use the mean function of the statistics module to calculate the average of a list. None None Use the starter…arrow_forwardI need help writing a C++ code. I need help writing a program that uses a structure to score the following information on a company division.: Division name( East, West, North, South)Quarter (1,2,3,4) Quarterly salesThe user should be asked for the four Quarters' sales figures for the east, west, north, and south divisions. The information for each quarter for each division needs to be written to a file.arrow_forwardThe name of the get line function won't print out in case: 3 It prints out the rest of the data but not the name. #include "stdafx.h" #include <iostream>#include <limits>#include <cstdlib> #include <ctime>#include <string>#include <vector>#include <cctype>#include <iterator>#include <algorithm>#include <cmath>#include<windows.h>#include <conio.h> using namespace std; struct donor{ string donor_name[50];double donor_amount[50];int department_donation[50];}; string find_name; double *NHTS;double *PBL;double *PTK;double *SEA;int search_display;int contributor;int display;int choice; int main(){here:cout << "\n";cout << " ************************************************************" << endl;cout << " ** ==Menu== **" << endl;cout << " ** **" << endl;cout << " ** **" << endl;cout << " ** **" << endl;cout << " ** 1. Add a contributor. **"…arrow_forward
- True or false: setInterval() executes a function repeatedly until the interval is cleared by clearInterval() using the ID returned by setInterval(). О а. True O b. Falsearrow_forwardPython: On-line Grocery Shopping Use grocery py in Canvas to start your program. It contains two dictionaries: stock and price EX: stock key/value pairs EX: price key/value pairs tomato soup 20 tomato soupP 1.85 cheese 10 cheese 3.99 Create a two functions: first called grocery_cost(food), where food can be one item or a list of items from the stock and price dictionaries, the second is called stock_check(stock_list) where a store manager can check if stock numbers are at a minimum value. The first function loops through the argument food, notes the price, checks the stock, calculates and prints the total cost and changes the stock number. You will need to use a for statement to loop through the items in food and an if statement to check and update the stock. The second function loops through each item in the stock dictionary and uses an if- statement to determine if stock is less than 5.arrow_forwardBASH FLOW CHART: Create a flow chart to describe an algorithm that takes a text file with format ID,FirstName,Last Name,Street,City and appends a user ID field consisting of a C followed by theemployee ID. For example, the first entries in Lab 2's employees.txt are:0,Douglas L,Eberhard,Addenda Circle,Cornwall1,Elizabeth Sua,Hemauer,Wyatt Way,Peterborough2,Bailey Rae,Lopez,Turnagain Street,Sault Ste. MarieAfter processing, the entries should be:0,Douglas L,Eberhard,Addenda Circle,Cornwall,C01,Elizabeth Sua,Hemauer,Wyatt Way,Peterborough,C12,Bailey Rae,Lopez,Turnagain Street,Sault Ste. Marie,C2arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
functions in c programming | categories of function |; Author: Education 4U;https://www.youtube.com/watch?v=puIK6kHcuqA;License: Standard YouTube License, CC-BY