Question

Modify the following given Java program. You are expected to modify the supplied Exercise1.java to print...

Modify the following given Java program. You are expected to modify the supplied Exercise1.java to print just the last lines of each paragraph in HTML format. Copy and paste the Sample input on the console then print the Expected output.

import java.util.Scanner;

public class Exercise1 {
/** A simple static string for HTML & table header. */
private static final String HTMLHeader =
"<!DOCTYPE html>\n"
+ " <html>\n"
+ " <head>\n"
+ " <title>CSE: Exercise 1</title>\n"
+ " </head>\n"
+ " <body>\n"
+ " <table border=1>";
  
/** A simple static string to print HMTL footer. */
private static final String HTMLFooter =
" </table>\n"
+ " </body>\n"
+ "</html>

public static void main(String[] args) {
System.out.println(HTMLHeader);
Scanner keyboard = new Scanner(System.in);

while (keyboard.hasNextLine()) {
String line = keyboard.nextLine();
System.out.println(" <tr><td>" + line + "</td></tr>");
}
System.out.println(HTMLFooter);
}
}

Sample input:

para #1

welcome.

para #2: Introduction

This is a simple test line

to create a 2 line para

conclusion of inputs

This para is the last para.

It has 3 lines

3 lines including this one and 3 blank lines at end

Last paragraph with 1 line

Expected output:

<!DOCTYPE html>

<html>

<head>

<title>CSE: Exercise 1</title>

</head>

<body>

<table border=1>

<tr><td>welcome. </td></tr>

<tr><td>to create a 2 line para</td></tr>

<tr><td>3 lines including this one and 3 blank lines at end</td></tr>

<tr><td>Last paragraph with 1 line</td></tr>

</table>

</body>

</html>

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

Code: I am not able to post the code(because of html syntax in it), HomeworkLib is not allowing so I am pasting the screenshot of the code

Output:

Add a comment
Know the answer?
Add Answer to:
Modify the following given Java program. You are expected to modify the supplied Exercise1.java to print...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • HTML/CSS: Modify the table you created in hands-on exercise 8.1 to be centered on the page,...

    HTML/CSS: Modify the table you created in hands-on exercise 8.1 to be centered on the page, use a background color of #CCCC99, and display text in arial or the browser default sans-serif font. Configure this table using CSS instead of obsolete HTML attributes. Place an e-mail link to yourself on the web page. Save the file as mytable.html. HERE IS THE CODE FOR 8.1: <!DOCTYPE html> <html lang="en"> <head> <title>Practice with Tables</title> <meta charset="utf-8"> </head> <body> <table border="1" > <caption>School...

  • CS 602 Server Side development hw1c please explain and comment the following html code <b>Employees with...

    CS 602 Server Side development hw1c please explain and comment the following html code <b>Employees with Last Name {{name}}</b> <hr/> <table border=1>     <tr><th>Id</th><th>First Name</th><th>Last Name</th></tr>     {{#each employees}}        <tr>           <td>{{this.id}}</td>           <td>{{this.firstName}}</td>           <td>{{this.lastName}}</td>        <tr>     {{/each}} </table> part two <!doctype html> <html> <head>    <title>CS602 HW2</title> </head> <body> <header>    <img src="/images/bu-logo.gif" alt="logo"> </header> <h3>CS602 HW2 - Your Name</h3> <a href="/addEmployee">Add Employee</a> <hr/>       {{{body}}} </body>...

  • How do I make these sheets into three different tabs for one website? This is all...

    How do I make these sheets into three different tabs for one website? This is all using HTML. - Chade's Bicycle Company <!DOCTYPE html> <html> <head> <img src="Chade'sLogo.png"> </head> <body bgcolor= "white"> <center> Welcome to Chade's Bicycle Company!</center> <center> We aim towards making our customers happy. </center> <br> <center> Chade's Bicycle Company </center> <center>2900 Bicycle Ave.</center> <center>Seattle, Washington</center> <center>98101</center> <br> <center><img src="HappyCustomer.png" alt="Satisfied customers"></center> <br> <p align="right">Our mission statement:</p> <p align="right">Bicycles have always been a </p> <p align="right">positive part of...

  • Look at the following illustrated output for an HTML and a css given below <!DOCTYPE html>...

    Look at the following illustrated output for an HTML and a css given below <!DOCTYPE html> <head> <title>TABLE with STYLE SHEET</title> <meta charset="utf-8" /> <meta name="description" content="Godaddy Webpage original" /> <link rel = "stylesheet" href="GoDaddy_assignment_1.css"> <body> <img src= "GoDaddy.png"/> <p>Welcome to:<strong>webhamster.com</strong></br> This web page is parked<strong>Free</strong>courtesy of <a class="aclass1" href ="https://www.godaddy.com">GoDaddy.com</a></p> <h1>Want to buy<span class ="span2">webmaster.com ?</span></h1> <div class ="div1"> <a class ="aclass2" href="https://www.godaddy.com">Learn How</a> </div> </hr> <button>Search Ads</button> </body> </html> “ QUESTION continued Given the corresponding css file .aclass1{color:purple;}...

  • i'm having trouble with 1 and 3 using html, javascript and jquery 1) Change the "Search"...

    i'm having trouble with 1 and 3 using html, javascript and jquery 1) Change the "Search" link on the left to a button that when clicked, hide all the fields on the form and display the text "This is a search feature..." 3) When the user fills the form and clicks "Login", the values inputted should be displayed in the empty row (under Login) of the page. The display should be in the form: Student ID: <input value> Student Name:...

  • You will write a single java program called MadLibs. java.

    You will write a single java program called MadLibs. java. This file will hold and allow access to the values needed to handle the details for a "MadLibs" game. This class will not contain a maino method. It will not ask the user for any input, nor will it display (via System.out.print/In()) information to the user. The job of this class is to manage information, not to interact with the user.I am providing a MadLibsDriver.java e^{*} program that you can...

  • Modify the program that you wrote for the last exercise in a file named Baseball9.java that...

    Modify the program that you wrote for the last exercise in a file named Baseball9.java that uses the Player class stored within an array. The program should read data from the file baseball.txt for input. The Player class should once again be stored in a file named Player.java, however Baseball9.java is the only file that you need to modify for this assignment. Once all of the input data from the file is stored in the array, code and invoke a...

  • java Fill in the blanks to complete the following recursive program. It shou print a pattern...

    java Fill in the blanks to complete the following recursive program. It shou print a pattern like the one below. using System.out.println. Assume you have method String nspaces(n) which returns a string containing n spaces. You should not write nspaces.) The pattern below is of size 3. The first line has one space before the while the middle line has 3 spaces before the .. The program should work for any positive size. 3 public static gt ( if( }...

  • Prelab Exercises Your task is to write a Java program that will print out the following...

    Prelab Exercises Your task is to write a Java program that will print out the following message (including the row of equal marks): Computer Science, Yes!!!! ========================= An outline of the program is below. Complete it as follows: a. In the documentation at the top, fill in the name of the file the program would be saved in and a brief description of what the program does. b. Add the code for the main method to do the printing. //...

  • For this problem, you will use the sample code given in the textbook (Uploaded to Canvas)...

    For this problem, you will use the sample code given in the textbook (Uploaded to Canvas) as a template. Modify the program so that it reads the webpage https://openlibrary.org/ and prints book category title and book category count as a table: No user input is required. Your challenge is understanding the structure of the web page contents and reading the correct data you are interested in. In Java sample text import java.io.IOException; import java.net.URL; import java.util.Scanner; /** This program prints...

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