Starting Out with C++: Early Objects
8th Edition
ISBN: 9780133360929
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: Addison-Wesley
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 13.3, Problem 13.13CP
Make the required changes to the following program so it writes its output to the file output.txt instead of to the screen.
#include <iostream>
using namespace std;
int main()
{
cout << "Today is the first day\n";
cout << "of the rest of your life.\n";
return 0;
}
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Can you please explain this part again?
Date::Date :day(1),month(1),year(2000)
{
}
Is it written this way? I am a little confused about how to write this portion at the start in the Date.cpp file, can you please rewrite this part more clearly?
Language: Pyhon.
Processing: Mode 3.54 (Jonathan Feinberg)
Please post sketch fle code.
Create a sketch named boston pass. This program will tell the user whether they passed a course or not Please read the entire question before starting.
Create the following variables using an appropriate name and datatype (do not name them first variable, etc.)
First variable: keeps track of the student mark (whole number)
Second variable: keeps track of a Boolean value indicating if the student passed
Third variable: keeps track of amount the student passed or failed by (whole number)
Create the following functions using appropriate names (do not name them first function, etc.)
First function: accepts one numeric value, purpose is to see if a student passed the course (50 or more), returns a true or false value.
Second function: accepts one numeric value, purpose is to see how much more or less than 50 the student received, returns the amount higher or lower
than 50.
Third function: accepts one…
(16) 6. You want to write a Java application that creates a while loop that runs until the user enters a 0 as input. Each time the while loop runs, it displays a menu of three choices as will be shown in the sample run
below. When the program reads in the user's choice, that choice should be read in as a String called choiceStr. Then, choiceStr should be converted into an int called choice by using the code below:
int choice Integer.parseInt(choiceStr);
If the user enters a 1 for choice == 1, the program will print "Choice 1" to the screen. If the user enters a 2 for choice == 2, the program will print "Choice 2" to the screen. Here is a sample run:
0 - to quit
1
to print Choice 1
2 to print Choice 2
Enter choice: 1
Choice 1
0 - to quit
1 to print
Choice 1
2 to print Choice 2
Enter choice: 1
Choice 1
0
to quit
1
to print Choice 1
2 to print Choice 2
Enter choice: 2
Choice 2
0 - to quit
1 to print Choice 1
2 to print Choice 2
Enter choice: 0
Chapter 13 Solutions
Starting Out with C++: Early Objects
Ch. 13.1 - Name three different C++ classes that can be used...Ch. 13.1 - Name three different C++ classes that can be used...Ch. 13.1 - What is the purpose of the second parameter to the...Ch. 13.1 - Why is it important for a program to close an open...Ch. 13.1 - Which file open flag causes all output to take...Ch. 13.1 - Which file open flag causes the contents of an...Ch. 13.1 - What happens if ios: :out is used by itself to...Ch. 13.1 - What happens if ios::out is used by itself to open...Ch. 13.1 - Write a sequence of C++ statements that reads in...Ch. 13.1 - Write a sequence of C++ statements that reads in...
Ch. 13.1 - Show how to use the constructor of the fstream...Ch. 13.1 - Consider two parallel arrays of the same size, one...Ch. 13.3 - Make the required changes to the following program...Ch. 13.3 - Describe the purpose of the eof member function.Ch. 13.3 - Assume the file input.txt contains the following...Ch. 13.3 - Describe the difference between reading a file...Ch. 13.3 - Describe the difference between the getline...Ch. 13.3 - Describe the purpose of the put member function.Ch. 13.3 - What will be stored in the file out.dat after the...Ch. 13.3 - The following program skeleton, when complete,...Ch. 13.5 - Write a short program that opens two files...Ch. 13.5 - How would the number 479 be stored in a text file?...Ch. 13.5 - Describe the differences between the write member...Ch. 13.5 - What arc the purposes of the two arguments needed...Ch. 13.5 - What are the purposes of the two arguments needed...Ch. 13.5 - Describe the relationship between fields and...Ch. 13.5 - Prob. 13.27CPCh. 13.7 - Describe the difference between the seekg and the...Ch. 13.7 - Describe the difference between the tellg and the...Ch. 13.7 - Describe the meaning of the following file access...Ch. 13.7 - What is the number of the first byte in a file?Ch. 13.7 - Briefly describe what each of the following...Ch. 13.7 - Describe the mode that each of the following...Ch. 13 - Prob. 1RQECh. 13 - Before a file can be used, it must first beCh. 13 - When a program is finished using a file, it shouldCh. 13 - The__________ header file is required for file I/O...Ch. 13 - Prob. 5RQECh. 13 - The_____________ file stream data type is for...Ch. 13 - The____________ file stream data type is for input...Ch. 13 - The ______ file stream data type is for output...Ch. 13 - Write a statement that defines a file stream...Ch. 13 - Write a statement that defines a file stream...Ch. 13 - Write a statement that defines a file stream...Ch. 13 - Write two statements that use the people file...Ch. 13 - Write two statements that use the pets file stream...Ch. 13 - Write two statements that use the places file...Ch. 13 - If a file fails to open, the file stream object...Ch. 13 - Write a program segment that defines a file stream...Ch. 13 - The same formatting techniques used with ______...Ch. 13 - The ______ member function reports when the end of...Ch. 13 - The ______ function reads a line of text from a...Ch. 13 - The _______ member function reads a single...Ch. 13 - The _____ member function writes a single...Ch. 13 - Prob. 22RQECh. 13 - Prob. 23RQECh. 13 - Prob. 24RQECh. 13 - In C++, _______ provide a convenient way to...Ch. 13 - The _______ member function writes raw binary data...Ch. 13 - The _______ member function reads raw binary data...Ch. 13 - The ______ operator is necessary if you pass...Ch. 13 - In _______ file access, the contents of the file...Ch. 13 - In _____ file access, the contents of a file may...Ch. 13 - The _______ member function moves a files read...Ch. 13 - The ______ member function moves a files write...Ch. 13 - The _______ member function returns a files...Ch. 13 - The _______ member function returns a files...Ch. 13 - The ______ mode flag causes an offset to be...Ch. 13 - The ______ mode flag causes an offset to be...Ch. 13 - The ______ mode flag causes an offset to he...Ch. 13 - A negative offset causes the files read or write...Ch. 13 - Give a pseudocode algorithm for determining the...Ch. 13 - Give a pseudocode algorithm for comparing two...Ch. 13 - Prob. 41RQECh. 13 - Suppose that you have two text files that contain...Ch. 13 - Each of the following programs or program segments...Ch. 13 - File Previewer Write a program that asks the user...Ch. 13 - File Display Program Write a program that asks the...Ch. 13 - Punch Line Write a program that reads and prints a...Ch. 13 - Tail of a File Write a program that asks the user...Ch. 13 - String Search Write a program that asks the user...Ch. 13 - Sentence Filter A program that processes an input...Ch. 13 - File Encryption Filter File encryption is the...Ch. 13 - File Decryption Filter Write a program that...Ch. 13 - Letter Frequencies The letter e is the most...Ch. 13 - Put It Back C++ input stream classes have two...Ch. 13 - Prob. 11PCCh. 13 - Insertion Sort on a File II Modify the program...Ch. 13 - Prob. 13PCCh. 13 - Prob. 14PCCh. 13 - Inventory Program Write a program that uses a...Ch. 13 - Inventory Program Write a program that uses a...Ch. 13 - Group Project 17. Customer Accounts This program...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
In Exercises 1 through 52, determine the output produced by the lines of code. DimdtAsDate=1/2/2020MessageBox.S...
Introduction To Programming Using Visual Basic (11th Edition)
Repeat Programming Project 5 of Chapter 2, but include input checking. Display the change only if a valid price...
Java: An Introduction to Problem Solving and Programming (8th Edition)
Describe how the average of a collection of numbers can be computed more rapidly with a multiprocessor machine ...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Dictionaries are not sequences.
Starting Out with Python (4th Edition)
Describe the primary differences between the conceptual and logical data models.
Modern Database Management
What difficulties can result from not keeping clamping forces low in designing jigs and fixtures?
Degarmo's Materials And Processes In Manufacturing
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
- please do not use java Your program must use the following functions: printHeader(…): prints the two lines header of the table shown in the sampleoutput getData(…): receives a string representing line of text read from file. Itvalidates and returns name, job code and days worked, and a Boolean value ofTrue of the line contains valid data or False if the line contains faulty data. computeSalary(…):receives the job code and days worked and computes and returnsthe employee salary main():Opens input file for reading, reads data from file, calls variousfunctions and prints resultsarrow_forwardClick on the buttons below to view all parts of the assignment. 3 When reading data from a text file, it is common to see numbers such as 12,345, $20, or 195*. Write a function that cleans a string containing digits by removing any characters that are not a digit or a - sign. Then convert to an integer and return the result. 1 2 numbers.cpp 1 #include 2 #include 13 14 using namespace std; /** } Cleans a string containing an integer and converts it. @param number a string containing an integer and possibly extraneous */ int clean(string number) CodeCheck characters @return the value of the number inside the string Resetarrow_forwardExpense Pie Chart (in python) Create a text file that contains your expenses for last month in the following categories: -Rent -Gas -Food -Clothing -Car Payment -Misc Write a Python program that reads the data from the file and uses matplotlib to plot a pie chart showing you how you spend your money.arrow_forward
- Exercise #2 Frequency Analysis: One of the oldest approaches to breaking a code is to perform a frequency count of letters. Write a C++ program to perform a frequency count by reading the text from a file (code.txt). Your program should output how many A's are there in the text, how many B's are there, and so on. Note that the program will not make any distinction between uppercase and lowercase letters. It will output the results to the screen and in a text file (count.txt) Sample output (for code.txt): A: 3 B: 3 C: 23 D: 13 E: 41 F: 4 G: 9 H: 15 1:44 J: 1 K: 0 L: 7 M: 9 N: 33 O: 16 P: 4 Q:0 R: 22 S: 24 T: 27 U: 8 V: 5 W: 1 X: 0 Y: 4 Z: 0arrow_forward// Swap.cpp - This program determines the minimum and maximum of three values input by // the user and performs necessary swaps. // Input: Three int values. // Output: The numbers in numerical order. #include <iostream> using namespace std; int main() { // Declare variables int first = 0; // First number int second = 0; // Second number int third = 0; // Third number int temp; // Used to swap numbers const string SENTINEL = "done"; // Named constant for sentinel value string repeat; bool notDone = true; //loop control // Get user input cout << "Enter first number: "; cin >> first; cout << "Enter second number: "; cin >> second; cout << "Enter third number: "; cin >> third; while(notDone == true){ // Test to see if the first number is greater than the second number // Test to see if the second number is greater than the third number // Test to…arrow_forwardTranscribed Image Text Problem 3) Create a text file that contains the following information: John Doe 2005 124.80 36 Note that the fist line represents the name of the client, the second line represents the year in which the client started an account with this insurance company. The third line represent the monthly payment for the insurance. The fourth line represents the number of months left in the insurance policy. Write a C++ program that will read this file and will display the client's name, the number of years for which this client has been with the company, and the remaining amount they have to payarrow_forward
- Hi, c++ help Please see my code The code reads two numbers from a file and creates a dice which must be played a certain amount of times (dertimined by input file). The code must then output the results of the multiple dice rolls. For line 1 **the numbers in brackets are the results of the multiple dice roll while the last number is the sum of the throws for the first die As you can see for the first line everything adds up correctly as the results of the dice (in brackets) are summed up correctly (last number) For the second row and all other following rolls, the code adds the rolls of the new dice and the result of the previous sum to get the new sum. This should not happen, I want the sum of each rows to be displayed on the end of each line The correct code should be display **please don't output comment [2] - [4 ]-[5] - 11 //dice rolled 3 times and sum is 11 [1] - [1 ]-2 //dice rolled 2 times with sum 2arrow_forward// LargeSmall.cpp - This program calculates the largest and smallest of three integer values. #include <iostream> using namespace std; int main() { // This is the work done in the housekeeping() function // Declare and initialize variables here int largest; // Largest of the three values int smallest; // Smallest of the three values // Prompt the user to enter 3 integer values // Write assignment, add conditional statements here as appropriate // This is the work done in the endOfJob() function // Output largest and smallest number. cout << "The largest value is " << largest << endl; cout << "The smallest value is " << smallest << endl; return 0; }arrow_forwardComplete the concat program which opens and prints the files on the command line to the screen. cmdline.cpp #include #include using namespace std; 4 int main(int argc, char* argv[]) { 5 8 9 10 a1.txt Alice was beginning to get very tired of sitting by her sister on the 2 bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in 1. a2.txt book her sister was reading, but it had no pictures or conversations in it, 'and what is the use of a book,' thought Alice 'without pictures or 3 1. conversation?' a3.txt So she was considering in her own mind (as well as she could, for the hot day made her feel very sleepy and stupid), whether the pleasure 3 1 of making a daisy-chain would be worth the trouble of getting up and m1.txt 1 "And God created great whales." --GENESIS. m2.txt "Leviathan maketh a path to shine after him; One would think the deep 2 to be hoary." -- JOB. m3.txt "Now the Lord had prepared a…arrow_forward
- Program C Loop, pls help ASAP int getNum(); /*accepts input from the user.*/ void display(int num); /*prints the number pattern*/ ---------------------------------------------------------------------arrow_forwardC Program WithOut Use "fgetc"arrow_forward// JumpinJava.cpp - This program looks up and prints the names and prices of coffee orders. // Input: Interactive // Output: Name and price of coffee orders or error message if add-in is not found #include <iostream> #include <string> using namespace std; int main() { // Declare variables. string addIn; // Add-in ordered const int NUM_ITEMS = 5; // Named constant // Initialized array of add-ins string addIns[] = {"Cream", "Cinnamon", "Chocolate", "Amaretto", "Whiskey"}; // Initialized array of add-in prices double addInPrices[] = {.89, .25, .59, 1.50, 1.75}; bool foundIt = false; // Flag variable int x; // Loop control variable double orderTotal = 2.00; // All orders start with a 2.00 charge // Get user input cout << "Enter coffee add-in or XXX to quit: "; cin >> addIn; // Write the rest of the program here. return 0; } // End of main()arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C - File I/O; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=cEfuwpbGi1k;License: Standard YouTube License, CC-BY
file handling functions in c | fprintf, fscanf, fread, fwrite |; Author: Education 4u;https://www.youtube.com/watch?v=aqeXS1bJihA;License: Standard Youtube License