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, Loose-leaf Edition (10th Edition)
Additional Engineering Textbook Solutions
Web Development and Design Foundations with HTML5 (8th Edition)
Digital Fundamentals (11th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Concepts Of Programming Languages
Software Engineering (10th Edition)
- (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_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_forwardData 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_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_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_forwardProblem Definition You are provided with a text file (employees.txt) containing a number of text lines. Each line contains a record of one employee. Each record has three attributes: Title: string, Prof. (Professor) or Dr. (Doctor). First and Last names: string. Salary: float number. The attributes are separated by the character (',). Figure 1.a, 1.b, and 1.c show a sample of employees.txt files. Dr., Julia Scott, 141518 Dr., Julia Scott, 141518 Prof.,Joan Stewart, 111673 Mr.,Ali Al-shukaili,122311 Prof., Sana Al-Abri, 131673 Prof.,Joan Stewart Dr., Fadi A1-Rasdhi, 153790 Ms., Salwa Al-Youssfi, 111675 Dr., Daniel Cooper, 153790 Dr., Lillian Brown, unknown Dr. :Benjamin Russell:117642 Dr., Daniel Cooper, 153790 Dr., Lillian Brown, 67251 Dr., Benjamin Russell,117642 Prof., Patrick Bailey, 72305 Dr., Ralph Flores, 118457 Dr., Douglas Flores, 181793 Dr., Lillian Brown, 67251 Figure 1.b: A sample of the text file 'employees.txt" Figure 1.a: A sample of the text file 'employees.txt' without…arrow_forward
- please solve these Part 4 Write a program that creates and stores student grades.Your program should start by asking users whether they would like to add orview stored grades. If the user selects the first option, they should be repeatedlyprompted for the names and module results (4CS001, 4CS015 and 4CI018) ofstudents until the users enters a blank string, storing the information in adictionary, before writing the data to a text file in JSON or CSV format.If the user selects to view student grades, any data stored in the results fileshould be read, loaded into a dictionary and presented to the user.Make sure to validate all inputs and utilise exception handling to avoid crashes.arrow_forwardgetline(myfile,str); * 2 points writes a line of text str from the file myfile reads a line of text to str from the file myfile writes a character str to the file myfile reads a character str from the file myfilearrow_forwardC Standard Library The C library stdio.h provides several key input/output functions. For questions 1-13, please match the names to the best descriptions of their functions. fclose() feof() fopen() c. Reads formatted input from a file fprintf() d. Reads formatted input from stdin printf() e. Reads a line from a file and stores it into a string sprintf() f. Reads a line from stdin and stores it into a string fscanf() g. Writes a string (plus newline character) to stdout scanf() h. Writes a string (plus newline character) to a file sscanf() i. Test the end-of-file indicator for a file fgets() j. Reads formatted input from a string fputs() k. Sends formatted output to a string gets() l. Close a file puts() m. Opens a filename using the given mode a. Sends formatted output to a file b. Sends formatted output to stdou c. Reads formatted input from a file d. Reads formatted input from stdin e. Reads a line from a file and stores it into a string f. Reads a line from stdin and stores…arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr