Question

Write a program that asks the user for his or her name, and then asks the user to enter a sentence that describes him or herself.

23. Personal Weeb Page Generator

Write a program that asks the user for his or her name, and then asks the user to enter a sentence that describes him or herself. Here is an example of the program's screen:

Enter your name: Julie Taylor [Enter]

<html> 
<head> 
</head> 
<body> 
  <center> 
    <h1>Julie Taylor</h1> 
  </center> 
  <hr /> 
  I am a computer science major, a member of the Jazz club, 
  and I hope to work as a mobile app developer after I graduate. 
  <hr /> 
</body>
</html>

Describe yourself: I am a computer science major, a member of the


Once the user has entered the requested input, the program should create an HTML file, containing the input, for a simple Web page. Here is an example of the HTML content, using the sample input previously shown:


# DO NOT use try/catch

# use Throws IOException

# using Java



3 0
Add a comment Improve this question Transcribed image text
✔ Recommended Answer
Answer #1

HTMLCreator.java:

import java.io.FileWriter;   // Import the class FileWriter
import java.io.IOException;  // Import the class IOException to handle errors
import java.util.Scanner;  //Import the class Scanner to get user input
public class HTMLCreator {
  public static void main(String[] args) throws IOException {   
      FileWriter fw = new FileWriter("sample.html");
      //open html file to write
      //scanner class to get input from users
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter your name: ");
      String name = sc.nextLine();
      System.out.println("Describe yourself: ");
      String description = sc.nextLine();
      //construct string to write into html file
      String str ="\n\n\n\t\n\t\t"+name+"\n\t"+description+"\n\n";
      //write string into file
      fw.write(str);
      //close file
      fw.close();
  }
}

Output:


Add a comment
Know the answer?
Add Answer to:
Write a program that asks the user for his or her name, and then asks the user to enter a sentence that describes him or herself.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • RandomGame.cpp (2pt) Write a program that asks the user to enter his/her name. Then begin a...

    RandomGame.cpp (2pt) Write a program that asks the user to enter his/her name. Then begin a do while loop that asks the user to enter a number between 1 and 10. Have the random number generator produce a number 1 and 10. Display the user’s name and both numbers to the screen. Compare the two numbers and report if the entered number is greater than, less than, or the same as the generated number. Ask the user if he/she’d like...

  • write in python idle Write full program that asks the user to enter his/her name then...

    write in python idle Write full program that asks the user to enter his/her name then repeatedly ask to enter the temperature in Fahrenheit and convert it to Celsius, the program should then prompt the user if he/she wants to continue or exit the program. The formula for conversion is: °C = (°F - 32) x 5/9 The program should use a function for the conversion. An Example of a sample run should appear on the screen like the text...

  • ***** JAVA ONLY ***** Write a program that asks the user to enter the name of...

    ***** JAVA ONLY ***** Write a program that asks the user to enter the name of a file, and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the file. Use Notepad to create a simple file that can be used to test the program. ***** JAVA ONLY *****

  • Write a program that asks for 'name from the user and then asks for a number...

    Write a program that asks for 'name from the user and then asks for a number and stores the two in a dictionary [called the_dicr) as key-value pair. The program then asks if the user wants to enter more data [More data ly/n]?) and depending on user choice, either asks for another name-number pair or exits and stores the dictionary key, values in a list of tuples and prints the list Note: Ignore the case where the name is already...

  • Write python program using IDLE Write a full program that asks the user to enter his/her...

    Write python program using IDLE Write a full program that asks the user to enter his/her name then repeatedly ask to enter the temperature in Fahrenheit and convert it to Celsius, the program should then prompt the user if he/she wants to continue or exit the program. The formula for the conversion is: °C = (°F - 32) x 5/9 The program should use a function for the conversion. An Example of a sample run should appear on the screen...

  • Write a program that asks the user for a student name and asks for grades until...

    Write a program that asks the user for a student name and asks for grades until the user enters a non-number input, it should then ask if the user wants to enter another student, and keep doing the process until the user stops adding students. The student’s must be stored in a dictionary with their names as the keys and grades in a list. The program should then iterate over the dictionary elements producing the min, max, and mean of...

  • Write a C program which asks the user to enter a name of a person and...

    Write a C program which asks the user to enter a name of a person and the program finds the number of that person. The number is displayed. Otherwise output "Not found". Your program have to check only given names. The program declares and initializes a two-dimensional array of characters that holds pairs of names and numbers. The array can hold 10 strings, each capable of holding up to 79 characters. Array elements are following: "Adam", "585-5622", "Mark", "505-8446", "Austin",...

  • Write a program which asks the user to enter a number. While the number is outside...

    Write a program which asks the user to enter a number. While the number is outside the range of 50 to 65 (exclusive). print "This is not valid input." and ask the user to re-enter a number. Remember to include a comment at the start of the program. 7 A- B I - : F F 2

  • 1. Creatc a lava program thal asks the user to cnter his/her first name and last...

    1. Creatc a lava program thal asks the user to cnter his/her first name and last namc, in a single linc and separaled by a spacc. The program should output separately the first namc and the last name. (Use the Scanner class.) 2. Create a Java program thal asks the user for a medium (air, water or sleel), and outputs the speed of sound in thal medium (1 100 feclsec in air, 4900 feesec in water and 16,400 feet sec...

  • Write a program that asks the user for the name of an image, the name of an output file. Your pro...

    Write a program that asks the user for the name of an image, the name of an output file. Your program should then save the upper right quarter of the image to the output file specified by the user. A sample run of your program should look like: Enter image file name: hunterLogo.png Enter output file: logOUR.png which would have as input and output: HUNTER ITER The City University of New York Hint: See sample programs from Lectures 3 and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT