Assume the file input.txt contains the following characters:
What will the following program display on the screen?
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
fstream inFile("input.txt", ios::in);
string item;
inFile >> item;
while (!inFile.fail())
{
cout <<item<< endl;
inFile >> item;
}
return 0;
}
Want to see the full answer?
Check out a sample textbook solutionChapter 13 Solutions
Starting Out With C++: Early Objects (10th Edition)
Additional Engineering Textbook Solutions
Modern Database Management
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Web Development and Design Foundations with HTML5 (8th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
Electric Circuits. (11th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
- The stream member function flags with no arguments resets the stream’s format state. T/Farrow_forward(Data processing) Write a C++ program that reads the file created in Exercise 4, permits the user to change the hourly wage or years for any employee, and creates a new updated file.arrow_forward(Data processing) Write a C++ program that reads the file created in Exercise 4 one record at a time, asks for the number of hours each employee worked each month, and calculates and displays each employee’s total pay for the month.arrow_forward
- (Data processing) Write a C++ program that allows the user to enter the following information from the keyboard for each student in a class (up to 20 students): Name Exam 1 Grade Exam 2 Grade Homework Grade Final Exam Grade For each student, your program should first calculate a final grade, using this formula: FinalGrade=0.20Exam1+0.20Exam2+0.35Homework+0.25FinalExam Then assign a letter grade on the basis of 90100=A,8089=B,7079=C,6069=D, and less than 60=F . All the information, including the final grade and the letter grade, should then be displayed and written to a file.arrow_forwardC++ Programming Write a C++ program using file handling in which it will read the code from the text file and then display the syntax errors in the output.arrow_forward#include "Bank.h" #include <iostream>#include <fstream>#include <string>#include <vector> using namespace std; int main() { Account** accounts = new Account * [10]; ifstream infile; infile.open("bank2.txt"); if ( !infile ) cerr << "File cannot be opened" << endl; else cout << "File Opened" << endl; string operationType; int totalAccount = 0; while (infile >> operationType) { if (operationType == "Saving") { int id; double initialBalance, minimumBalance, annualInterestRate; infile >> id >> initialBalance >> minimumBalance >> annualInterestRate; Saving* savingAccount = new Saving(); savingAccount->setInterest(annualInterestRate); savingAccount->setMinBalance(minimumBalance); accounts[totalAccount] = savingAccount; accounts[totalAccount]->setID(id);…arrow_forward
- Data File: Example #1AAAAABBBBBCCCCCDDDDDAAEBCBAFBBCDCECDADDEFEEFFFExample #2AAATAABTBBBBCCCCTCDDTDDDAASAABBSBBCCSCCDSDDDEEEAEEFBFFFDDF Write a program that will give the user a brief introduction, then allow the user to type in the name of the file to be analyzed, the name of the data file to generate, and then process the data to match the output that is shown below. This DNA test measures the various parts of the sequence and assigns them a letter. While the letters could be anything from A to Z, the only letters that matter for this test are the letters {A,B,C,D} all other letters can be ignored completely. A sample will be tested, given a length of time and then tested again. Each time the scientist will generate a line of data. Here is one Example: Example #1 AAAAABBBBBCCCCCDDDDD AAEBCBAFBBCDCECDADDEFEEFFF At first glance the sample looks significantly different after the second test. But if you look at the data, you will note that since we only care about A,B,C,D’s that the…arrow_forwardUser Input Program and Analysis Demonstrate an understanding of C++ programming concepts by completing the following: Program: Create a C++ program that will obtain input from a user and store it into the provided CSC450_CT5_mod5.txt Download CSC450_CT5_mod5.txtfile. Your program should append it to the provided text file, without deleting the existing data: Store the provided data in the CSC450_CT5_mod5.txt file. Create a reversal method that will reverse all of the characters in the CSC450_CT5_mod5.txt file and store the result in a CSC450-mod5-reverse.txt file. Program Analysis: Given your program implementation, discuss and identify the possible security vulnerabilities that may exist. If present, discuss solutions to minimize the vulnerabilities. Discuss and identify possible problems that can result in errors for string manipulation of data. Your analysis should be 1-2 pages in length. Screenshot shows txt file. CSC450_CT5_mod5.txt reads: Please be sure to append your data…arrow_forwardProgramming Assignment 1 #include <iostream> #include<iomanip> #include<fstream> #include<sstream> #include<string.h> using namespace std; //Define the main function int main() { //Create the object of fstream class and opening the file ifstream inpfile("order.txt"); string fline; double sub_total, tax, shipping=14.95, grand_total, line_total; double priceA=17.46, priceB=10.13, priceC=2.11, priceD=23.13, priceE=74.56, priceF=1.11, priceG=9.34, priceH=3.45; cout<<"Thank You! Your order is summarized below: "<<endl; cout<<"-----------------------------------------------"<<endl; cout<<"| Product\t|Quantity\t|Line total |"<<endl; cout<<"-----------------------------------------------"<<endl; while (getline(inpfile, fline)) { istringstream ists(fline); string product; int quantity; if (!(ists >>product>> quantity)) {…arrow_forward
- program5_1.pyWrite a program that operates like a cashier terminal in a grocery store. It begins by prompting for the number of different items being purchased and then starts a loop. In the loop, the program should prompt for the item description, price and quantity of each item being purchased. These three values should be passed as arguments to a custom function that is defined in a separate module file. The imported function should print the subtotal for the item and return it to main. The total should be printed in main after the loop ends.arrow_forwardC++arrow_forwardC++ Write a code segment that creates an ofstream object named outfile, opens a file named numfile.txt, and associates it with outfile. Then write the contents of the variable data to the file, followed by a newline, then close the file.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr