homework problem HELP!

Hi, I have been struggling with this certain homework problem and any help/advice would be greatly appreciated! Here is the question:

Write a program that asks the user for their name, a sentence or two that describes themself, and a title for the web page. Here is an example of the program's screen:

Enter your name: Julie Taylor [enter]
Describe yourself: I am a Comp. Sci. major and a member of the Jazz Club.I hope to be a mobile app developer some day.
Enter a title for your web page: About Me [enter]

Once the user has entered the requesested input, the program should create an output file named the same as the user's title, with the extension html. After you program runs, the html file can be opened in a browser to display a simple web page.

<html>
<head>
<title>About Me</title>
</head>
<body>
<center>
<h1>Julie Taylor</h1>
</center>
<hr>
I am a Comp Sci. major and a member of the Jazz Club. I hope to be a mobile app developer some day.
<hr>
</body>
</htm>
you can hard code the tags and output; don't try to make a fancy generation tool.
just slip the input between the tags in your write statement.
Just create a main that asks for all the information, then pass the 3 things into a function that writes to a file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>

using namespace std;

int main()
{

   string title, name, description;
   
   cout << "Enter your name: " << endl;
   getline(cin, name);
   cout << "Describe yourself: " << endl;
   getline(cin, description);
   cout << "Enter a title for your web page: " << endl;
   getline(cin, title);
   
}


I'll leave out the code for the function, but be sure to create a temp string to add the title and ".html" together

You write to a file with, instead of console out (cout), your ofstream variable.
ie.
1
2
ofstream FileOut;
FileOut << "<html>" << endl;


And as jonnin said, just hardcode the tags.
Last edited on
Topic archived. No new replies allowed.