Assume the file input.txt contains the following characters:
What will the following program display on the screen?
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
fstream inFile (“input.txt”, ios: :in);
string item;
inFile >> item;
while (inFile)
{
cout << item << endl;
inFile >> item;
)
inFile.close();
return 0;
}
Want to see the full answer?
Check out a sample textbook solutionChapter 12 Solutions
Starting Out with C++ from Control Structures to Objects (9th Edition)
Additional Engineering Textbook Solutions
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Elementary Surveying: An Introduction To Geomatics (15th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Electric Circuits. (11th 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
- C++ formatting please Write a program (not a function) that reads from a file named "data.csv". This file consists of a list of countries and gold medals they have won in various Olympic events. Write to standard out, the top 5 countries with the most gold medals. You can assume there will be no ties. Expected Output: 1: United States with 1022 gold medals 2: Soviet Union with 440 gold medals 3: Germany with 275 gold medals 4: Great Britain with 263 gold medals 5: China with 227 gold medalsarrow_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_forwardplease 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_forward
- Files and Input #include <iostream>#include <fstream>#include <string>#include <iomanip>using namespace std; int main() { //Declare variables string employee; double RateOfPay, salary; int hours; cout << fixed << setprecision(2); ifstream in("WorkLoad.txt"); getline(in, employee); in >> RateOfPay >> hours; in.close(); salary = hours * RateOfPay; if (hours > 38) salary = (38 * RateOfPay) + ((hours - 38) * RateOfPay * 1.5); else salary = hours * RateOfPay; cout << employee << " worked " << hours << " hours at a rate of pay of " << RateOfPay << ". Due to the number of hours worked the employee did "; (hours > 38) ? cout << "" : cout << "not "; cout << "qualify for time and a half pay. The weekly salary for this employee is " << salary << endl; // open output file Salary.txt for writing…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_forwardprogram5_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_forward
- C++arrow_forwardUser Input Program and Analysis (Last answer to this question was incorrect.) 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. TXT FILE INFORMATION (Txt file should NOT…arrow_forwardC++arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr