C++
HTML files use tags enclosed in angle brackets to denote formatting instructions. For ex- ample, indicates bold, indicates italics, etc. If a web browser is displaying an HTML document that contains ‘<’ or ‘>’ then it may mistake these symbols for tags. This is a common problem with C++ files, which contain many <’s and >’s. For example, the line “#include ” may result in the browser interpreting as a tag. To avoid this problem, HTML uses special symbols to denote ‘<’ and ‘>’. The < symbol is created with the string “<” while the ‘>’ symbol is created with the string “>” . Write a program that reads in a C++ source file and converts all ‘<’ symbols to “<” and all ‘>’ symbols to “>” . Also add the tag
to the beginning of the file and
to the end of the file. This tag preserves whitespace and formatting in the HTML document. Your program should create a new file with the converted output. To implement this, you should write a function ‘convert’ that takes the input and output streams as parameters. As an example, given the following input file: #include 1 int main() { int x=4; if (x < 3) x++; cout << x << endl; } The program should produce a textfile with the following contents:
#include
int main() {
int x=4;
if (x < 3) x++;
cout << x << endl;
}
You can test your program with any .cpp file you have as input (Make sure to make a copy of the input file as you may loose it with incorrect File I/O). You should test your output file by opening it with a web browser. The contents should appear identical to the original source code.
#include <iostream>
#include <fstream>
#include <cstring>
#include <string>
#include <cstdlib>
using namespace std;
function void convert(ifstream inStream, ofstream
outStream){
// Input file to convert
string dataFile;
// Output file with .html on the end
string outputFileName;
char eachChar;
int i;
cout << "Enter file name: " << endl;
cin >> dataFile;
// Opening the file given by user
inStream.open(dataFile.c_str());
if (inStream.fail()) {
cout << "error in opening file." << endl;
exit(1);
}
// preparing the output result file
outputFileName = dataFile + ".html";
outStream.open(outputFileName.c_str());
// outputting <pre> tag
outStream << "<PRE>" << endl;
// reading file line by line
while (!inStream.eof()) {
inStream.get(eachChar); // reading each character
// replacing
'>' and '<' symbol
if (eachChar == '<') {
outStream
<< "<";
}
else if (eachChar=='>') {
outStream
<< ">";
}
else outStream <<
eachChar;
}
// finally outputting</pre> tag
outStream << "</PRE>" << endl;
inStream.close();
outStream.close();
cout << "Processing done... Check output file "
<< outputFileName << endl;
}
// mail
int main() {
ifstream inStream;
ofstream outStream;
convert(inStream, outStream);
}
C++ HTML files use tags enclosed in angle brackets to denote formatting instructions. For ex- ample,...
[C++]
Using Files—Total and Average Rainfall
Write a program that reads in from a file a starting month name, an
ending month name, and then the monthly rainfall for each month
during that period. As it does this, it should
sum the rainfall amounts and then report the total rainfall and
average rainfall for the period. For example, the output might look
like this: During the months of March–June the total rainfall was
7.32 inches and the average monthly rainfall...
I need help debugging this C++ prgram. What Am i doing wrong? //******************************************************** // This program reads two input files whose lines are //ordered by a key data field. This program should merge //these two files, writing an output file that contains //all lines from both files ordered by the same key field. // //********************************************************* #include <iostream> #include<string> #include<fstream> //prototype void mergeTwoFiles (ifstream&,ifstream&, ofstream&); using namespace std; int main() {string inFile1,inFile2,outFile; // input and output files ifstream in1; ifstream in2;...
Don't attempt if you can't attempt fully, i will dislike a nd negative comments would be given Please it's a request. c++ We will read a CSV files of a data dump from the GoodReads 2 web site that contains information about user-rated books (e.g., book tit le, publication year, ISBN number, average reader rating, and cover image URL). The information will be stored and some simple statistics will be calculated. Additionally, for extra credit, the program will create an...
Don't attempt if you can't attempt fully, i will dislike and negative comments would be given Please it's a request. c++ We will read a CSV files of a data dump from the GoodReads 2 web site that contains information about user-rated books (e.g., book titnle, publication year, ISBN number, average reader rating, and cover image URL). The information will be stored and some simple statistics will be calculated. Additionally, for extra credit, the program will create an HTML web...
It is a C++ program by using
inheritance and vectors
My professor said that all the files should be separate. like
File.cpp, File.h, Text.cpp,Text.h,Main.cpp
I already have these files
File.cpp
#include "File.h"
// Constructor of File that takes File name and type as
arguments
File::File(string type, string name) {
this->type = type;
this->name = name;
}
//returns the type.
string File::getType() {
return type;
}
//returns the name of file.
string File::getName() {
return name;
}
File.h
#ifndef __FILE_H__
#define...
I am having trouble trying to output my file Lab13.txt. It will
say that everything is correct but won't output what is in the
file. Please Help
Write a program that will input data from the file
Lab13.txt(downloadable
file);
a name, telephone number, and email
address.
Store the data in a simple local array to the main
module, then sort the array by the names. You should have several
functions that pass data by reference.
Hint: make your array large...
4.3Learning Objective: To read and write text files. Instructions: This is complete program with one Java source code file named H01_43.java (your main class is named H01_43). Problem: Write a program that prompts the user for the name of a Java source code file (you may assume the file contains Java source code and has a .java filename extension; we will not test your program on non-Java source code files). The program shall read the source code file and output...
C++ requirements The store number must be of type unsigned int. The sales value must be of of type long long int. Your program must properly check for end of file. See the section Reading in files below and also see your Gaddis text book for details on reading in file and checking for end of file. Your program must properly open and close all files. Failure to follow the C++ requirements could reduce the points received from passing the...
13.13 Final - Problem 2 (Chapter 8) Google Docs (20 points) Given the Document class below, you will write a basic version of Google Drive. Your program will store two lists of documents, one for documents the user has created and one for created documents the user has shared with a friend. The user will have a few options which you will need to implement (note: the menu will only be displayed once at the beginning of the program): Add...
Assignment Predator / Prey Objectives Reading from and writing to text files Implementing mathematical formulas in C++ Implementing classes Using vectors Using command line arguments Modifying previously written code Tasks For this project, you will implement a simulation for predicting the future populations for a group of animals that we’ll call prey and their predators. Given the rate at which prey births exceed natural deaths, the rate of predation, the rate at which predator deaths exceeds births without a food...