Starting Out with C++: Early Objects (9th Edition)
9th Edition
ISBN: 9780134400242
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
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
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…
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?
(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 (9th Edition)
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
Why is it easier to write a program in a high-level language than in machine language?
Starting Out with C++ from Control Structures to Objects (9th Edition)
Assuming that intNumber is an integer variable, what value will each of the following statements assign to it? ...
Starting Out With Visual Basic (7th Edition)
3.12 (Date Create a class called Date that includes three pieces Of information as data
members—a month (type ...
C++ How to Program (10th Edition)
What do you call a program that translates a high-level language program into a separate machine language progr...
Starting out with Visual C# (4th Edition)
What will the following program display? public class ReviewQuestion5 { public static void main(String[] args) ...
Starting Out with Java: From Control Structures through Objects (6th Edition)
What does the loop do in the sequential search algorithm? What happens when the value being searched for is fou...
Starting Out with Programming Logic and Design (4th Edition)
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
- 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_forwardProblem 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…arrow_forwardC++arrow_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_forwardC++ void print_stats(string filename); Notes: 1. Already a text file with the number of wins and switches from 10,000 games is made. 2. The function reads information from a text file that has recorded a simulation of a set of games. 3. The output generated is from a file called stats_large.txt from 10,000 computer vs computer games. Parameters: Filename: the file contains the following information in order: • The number of games played • Followed by the given number of this tuples of (0,1) each separated by a space: 0. The first number of this tuple is 1 for a winner game, o for a non winner game. 1. The second number of this tuple is 1 for the player having switched their choice, 0 if they did not switch Return: Prints the statistics for a series of "Let's Make a Deal" outcomes. The information is printed to the console in the following format: Statistical analysis of Let's Make a Deal Game In ***** games : Number of switch decisions: **** Number of wins when switching: ****…arrow_forward
- c++ programming languagearrow_forwardC++ Vector iteration: Sum of excess. Vector testGrades contains NUM_VALS test scores. Write a for loop that sets sumExtra to the total extra credit received. Full credit is 100, so anything over 100 is extra credit. Ex: If testGrades = {101, 83, 107, 90}, then sumExtra = 8, because 1 + 0 + 7 + 0 is 8.arrow_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_forward
- Program C Loop, pls help ASAP int getNum(); /*accepts input from the user.*/ void display(int num); /*prints the number pattern*/ ---------------------------------------------------------------------arrow_forward#include <iostream> #include <cmath> using namespace std; // declare functions void display_menu(); void convert_temp(); double to_celsius(double fahrenheit); double to_fahrenheit(double celsius); int main() { cout << "Convert Temperatures\n\n"; display_menu(); char again = 'y'; while (again == 'y') { convert_temp(); cout << "Convert another temperature? (y/n): "; cin >> again; cout << endl; } cout << "Bye!\n"; } // define functions void display_menu() { cout << "MENU\n" << "1. Fahrenheit to Celsius\n" << "2. Celsius to Fahrenheit\n\n"; } void convert_temp() { int option; cout << "Enter a menu option: "; cin >> option; double f = 0.0; double c = 0.0; switch (option) { case 1: cout << "Enter degrees Fahrenheit: "; cin >> f; c =…arrow_forward#include <iostream> #include <cmath> using namespace std; // declare functions void display_menu(); void convert_temp(); double to_celsius(double fahrenheit); double to_fahrenheit(double celsius); int main() { cout << "Convert Temperatures\n\n"; display_menu(); char again = 'y'; while (again == 'y') { convert_temp(); cout << "Convert another temperature? (y/n): "; cin >> again; cout << endl; } cout << "Bye!\n"; } // define functions void display_menu() { cout << "MENU\n" << "1. Fahrenheit to Celsius\n" << "2. Celsius to Fahrenheit\n\n"; } void convert_temp() { int option; cout << "Enter a menu option: "; cin >> option; double f = 0.0; double c = 0.0; switch (option) { case 1: cout << "Enter degrees Fahrenheit: "; cin >> f; c =…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