Question
C++: only use Strings in this question. Write a program to read the input file, shown below and write out the output file shown below.
C++: only use Strings in this question.
Write a program to read the input file, shown below and write out the output file shown below. Use only string objects and string functions to process the data. Do not use c-string functions or stringstream (or istringstream or ostringstream) class objects for your solution. The idea of the program is to read the text file into 4 variables and rearrange the output. please explain as you go through.
here is the start code i wrote (change if needed that okey):
#include
main() { string team,team2; string score,score2; ifstream myfile("input.txt"); /*if (myfile.is_open()) { while ( getline ) { cout << city << score<< ' '; } myfile.close(); }
else cout << "Unable to open file"; */ return 0;
}
Input File
Cincinnati 27, Buffalo 24 Detroit 31, Cleveland 17 Kansas City 24, Oakland 7 Carolina 35, Minnesota 10 Pittsburgh 19, NY Jets 6 Philadelphia 31, Tampa Bay 20 Green Bay 19, Baltimore 17 St. Louis 38, Houston 13 Denver 35, Jacksonville 19 Seattle 20, Tennessee 13 New England 30, New Orleans 27 San Francisco 32, Arizona 20 Dallas 31, Washington 16 |
Output File
Cincinnati over Buffalo 27 to 24 Detroit over Cleveland 31 to 17 Kansas City over Oakland 24 to 7 Carolina over Minnesota 35 to 10 Pittsburgh over NY Jets 19 to 6 Philadelphia over Tampa Bay 31 to 20 Green Bay over Baltimore 19 to 17 St. Louis over Houston 38 to 13 Denver over Jacksonville 35 to 19 Seattle over Tennessee 20 to 13 New England over New Orleans 30 to 27 San Francisco over Arizona 32 to 20 Dallas over Washington 31 to 16 |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started