Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
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
The beginning of the code is given below.
#include <stdio.h>#include <string.h>
typedef struct{char firstname[20];unsigned height;unsigned weight;} Person;
//You can use this functionvoid BufferCleaner(){ while(getchar()!='\n');}
void FileCleaner(){FILE *fp; fp = fopen("data/14w_2.txt", "w");fprintf(fp,""); fclose(fp);}
Rewrite problem 2(copy your solution from problem 2 and paste it into a separate file) and create a function called “calc_amount.” This function will take 4 integers for the change amount and convert that change into dollars. The dollar amount calculated will be passed back through the return statement, where the amount should be outputted in main. Please show work and code. See the start code below.
#include <iostream>#include <iomanip>
using namespace std;
int main() { int quarters, dimes, nickels, pennies;
// Ask for user input cout << "How many quarters do you have? "; cin >> quarters; cout << "How many dimes do you have? "; cin >> dimes; cout << "How many nickels do you have? "; cin >> nickels; cout << "How many pennies do you have? "; cin >> pennies; // Calculate the value of the coins double total = (quarters * 0.25) + (dimes * 0.10) + (nickels * 0.05) + (pennies * 0.01);
// Print the total cout <<…
In C++ PLEASE
Use the text file from Chapter 12, forChap12.txt. SEE BELOW
Write a program that opens a specified text file then displays a list of all the unique words found in the file.
Addition to the text book specifications, print the total of unique words in the file.
Text File = forChap12.txt
No one is unaware of the name of that famous English shipowner, Cunard. In 1840 this shrewd industrialist founded a postal service between Liverpool and Halifax, featuring three wooden ships with 400-horsepower paddle wheels and a burden of 1,162 metric tons. Eight years later, the company's assets were increased by four 650-horsepower ships at 1,820 metric tons, and in two more years, by two other vessels of still greater power and tonnage. In 1853 the Cunard Co., whose mail-carrying charter had just been renewed, successively added to its assets the Arabia, the Persia, the China, the Scotia, the Java, and the Russia, all ships of top speed and, after the Great Eastern, the biggest ever…
Chapter 3 Solutions
Starting Out With C++: Early Objects (10th Edition)
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 - Write C++ expressions for the following algebraic...Ch. 3 - Assume a program has the following variable...Ch. 3 - Prob. 11RQECh. 3 - Write a multiple assignment statement that can be...Ch. 3 - Write a pair of multiple assignment statements...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 - 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 - How Much Insurance? Many financial experts advise...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 - 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 - 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...
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
- What does function sqrt do? Which header file must be included to use the function sqrt? (3)arrow_forwardWhy does the file stream member function open's second argument exist?arrow_forwardThe problem statement is described in the problem_statement.pdf file. Write the solution into the fuzzy_phrases/solution.py. Please do not change the input and output contract of the def phrasel_search(P, Queries) -> [[string]] function as the testing of the code correctness will be done programmatically. Note - You can only use standard python libraries. ex - json, random, etc *** This is the most important one **Basically the folder that' contains the dictionary is in a json file called, sample.json, so you wanna have a code that apparently use two parameters and the phrase apparently loops through the queries , inside the json file where the dictionary is found in the json file called sample.json So in the screenshots below we have one that has the instructions which has to be followed and executed , the next one that follows should be an example, that says sample example python this is the problem statement supposed to be used to give you an idea , showing how you should…arrow_forward
- Plz I want you to rewrite this code in a good form // Include all the necessary libraries.#include <fstream>#include <iostream>#include <stdio.h>#include <string.h> using namespace std; class Student(){// Considering the max length of data entered (name) to// be 15.char data[15],data1[15];int n = 0, option = 0, count_n = 0;int m = 0, count_m = 0;// This is the initial mark alloted to a subject.string empty = "00";// Name of the file in which DB is stored.ifstream f("Example.txt");string line; // The following for loop counts the total number of// lines in the file.for (int i = 0; std::getline(f, line); ++i) {count_n++;} while (option != 6) {// This prints out all the available options in thecout << "WELCOME TO TECHNOLOGY COLLEGE MUSCAT"cout << "\nAvailable operations: \n1. Add New ""Students\n2."<< "Student Show\n3"<< "6. Exit\nEnter option: ";cin >> option; if (option == 1) {insert();}else if (option == 2) {show();}}} void…arrow_forwardFinish a C++ code. Assume the <iostream>, <fstream>, and <string> headers have already been included and that main() looks like this: (picture 1) Each row of the capitals.txt file contains the following data, in this order: The city (string, one word) The state (string, one word) The population (integer) (picture 2, of the capitals.txt text) Text to copy for the capitals.txt file: Phoenix Arizona 1660272 Austin Texas 964254 Ohio Columbus 892553 Indianapolis Indiana 867125 Denver Colorado 716492 Boston Massachusetts 694583 Nashville Tennesseee 635710 Sacramento California 466488 Atlanta Georgia 420003 Honolulu Hawaii 359870 Create a function named smallestCapital as follows: The function returns an integer.The function has 5 parameters:Two string arraysOne integer arrayAn ifstream objectAn integer for the length of the arraysThe function should be coded as follows:If the ifstream object did not open the file, return a value of -1.Otherwise, use a while loop to read…arrow_forwardi want ".h" header file Separate from this code "Your program must embrace modular programming technique should be menu-driven. Functions of similar operations can be grouped & stored as separate C files. Headerfiles are to be stored separately as .h files." #include <stdio.h> #include <stdlib.h>#include <string.h> struct vacc{char vaccName[15]; char vaccCode[2]; char country[15]; int qty; float population; }v[10]; // Function Declarations void create_inventory(); void update_vacc_qty(); int search_vaccine(); void display_vaccine(); // Main Function starts here int main() { int ch;do {printf("\n 1:create inventory");printf("\n 2: display vaccine info ");printf("\n 3: search vaccine");printf("\n enter your choice (0 to exit):");scanf("%d",&ch); switch (ch){case 1: create_inventory();break;case 2: display_vaccine();break;case 3: search_vaccine();break;default : break;} }while(ch!=0);return 0; } //Function to Create Vaccine.txt as per the given table void…arrow_forward
- Identify the number of syntax and/or logical error found in the code fragment below. (Assume all headers are included) int main(){ // Assume the file has one number per line fstrem f("file.text", ios:out); int n; for(int line = 1; line <= 10; line++) { f >> n; cout << line << ". " << n << endl; } return 0;}arrow_forwardThe template code must be incorporated into the following code after the template:// -- brief statement as to the file’s purpose //CSIS 111- ADD YOUR SECTION NUMBER //<Sources if necessary> // //Include statements #include <iostream> #include <string> using namespace std; //Global declarations: Constants and type definitions only -- no variables //Function prototypes int main() { //In cout statement below SUBSTITUTE your name and lab number cout << "Your name -- Lab Number" << endl << endl; //Variable declarations //Program logic //Closing program statements system("pause"); return 0; } //Function definitions That template must be placed in with this code: #include <iostream> //Program containing necessary header files#include <fstream> // used for file read and write operation#include <string>#include <cmath> // used for mathtype calculations #include <iomanip> //used for precision using namespace std; // function is…arrow_forwardThis C programming code is not run properly. Please fix this problem and solve this error. # include <stdio.h># include <string.h> int main( ){ // Declare the file pointer FILE *filePointer,*filePointer1 ; int n; printf("enter a key for encryption"); scanf("%d",&n); // Declare the variable for the data to be read from file char dataToBeRead[50]; filePointer = fopen("test.txt", "r") ; filePointer1 = fopen("final.txt", "w") ; // Check if this filePointer is null // which maybe if the file does not exist if ( filePointer == NULL ) { printf( "test.txt file failed to open." ) ; } else { printf("The file is now opened.\n") ; // Read the dataToBeRead from the file // using fgets() method while( fgets ( dataToBeRead, 50, filePointer ) != NULL ) {…arrow_forward
- here is a and b part plz solve c part #include <iostream>#include <string.h>#include <stdlib.h>#include <sstream>#include <cmath>using namespace std; int main(){ /*Variable declarations*/int higestDegree,higestDegree1;int diffDegree,smallDegree;std::stringstream polynomial,addpolynomial;/*prompt for degree*/std::cout<<"Please enter higest degree of polynomial"<<std::endl;std::cin>>higestDegree; std::cout<<"Please Enter highest degree of 2nd polynomial"<<std::endl;std::cin>>higestDegree1;int *cofficient=new int[higestDegree+1];//cofficient array creation for 1st polynomailint *cofficient1=new int[higestDegree1+1];//cofficient array creation for 2st polynomail /*taking cofficient for 1st polynomial*/std::cout<<"Please enter cofficient of each term from higest degree to lowest for 1st polynomial"<<std::endl;for(int i=0;i<=higestDegree;i++){std::cin>>cofficient[i];}/*taking cofficient for 2st…arrow_forwardPlease use C++ and only use libraries <iostream> and <cmath>. Also ultilize cin.ignore to let responses be recognized with a Y or Yes. Code in second pic needs to be included. Thank you!arrow_forwardModify C++ code. 1-if numberoftries used by user but not guess the correct answer print You can;t guess the correct random number and then print on second line" The correct random number is ------- "this. 2-Then ask from user if you want to play again or not if not then excute the program. Code: //included header file for basic input output stream #include <iostream> //included header file for file stream #include <fstream> //included header file to use rand() function #include <cstdlib> //included header file to use time() function #include <ctime> //included namespace using namespace std; //function to generate random number int generateRandom(); void tooLow(); void tooHigh(); void guessedCorrect(); void checkGuess(int guess, int randomNumber); void guessGame(); int generateRandom() { //use srand() function to change the random number after each execution srand((unsigned int) time(0)); //generated a random number between 1-50 through rand()…arrow_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