Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Java and HTML

  1. #1
    Junior Member
    Join Date
    Oct 2017
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java and HTML

    Hello I have a java question but I don't know how to combine it with html and how to create an web browser with my java code

    Try to solve the following problem. Note: Don't let the html code confuse you; as far as this problem is concerned it is simply text to be output in exactly the same way you have done for the other problems. A company requires that all its employees have a webpage. To date, a secretary has been asked to create each such page by hand. As a new engineer in a company's IT department you realise that the job can easily be done much cheaper, quicker and with less errors, using a computer program. Your boss thinks this is a great idea and asks you to immediately start work to design and implement such a program. The art department comes up with the stunning webpage layout shown below. You decide that the secretary should be able to run the program, input the new employee's name, their age, salary and a paragraph of comments about them, and have it automatically create and save the necessary html code in a file. This file can then be viewed using a standard web browser such as Internet Explorer, Chrome or Firefox.

    The html code corresponding to the art department's sample design is shown next to it. Notice that it is just special html tags, such as <p> & </p>, with the employee's details between them. You should define named constants for each of these tags (so that they can be reused and changed easily.) Initially, design your program so that it first gets all the necessary information from the user, and then displays the corresponding html on the system console.

    This is my code:


    import java.util.Scanner;

    public class heat {
    public static void main(String[] args)
    {
    Scanner in=new Scanner(System.in);


    String name=in.next();
    System.out.println("Enter the age:");
    int age=in.nextInt();

    System.out.println("Enter the salary:");
    double salary=in.nextDouble();

    System.out.println("Comments:");
    String comments=in.next();
    }
    }

    This is the html that teacher gave us:

    <!DOCTYPE html>

    <html>

    <head>
    <title>Derya's Home Page</title>
    </head>

    <body>

    <hr>
    <h1>Derya</h1>
    <p>Age: 18</p>
    <p>Salary: 1000.0</p>
    <p>Comments: Smart girl!</p>
    <hr>

    </body>

    </html>

  2. #2
    Member
    Join Date
    Aug 2017
    Location
    Northern Ireland
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java and HTML

    Do you know how to print to the system console?
    Tim Driven Development

Similar Threads

  1. how to decode the html tags in java?
    By swarupa.d in forum What's Wrong With My Code?
    Replies: 0
    Last Post: April 16th, 2014, 05:56 AM
  2. Creating HTML Forms in Java
    By Anitush in forum Java Theory & Questions
    Replies: 0
    Last Post: September 27th, 2013, 03:27 AM
  3. Java Script or HTML
    By ravi9999 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 1st, 2012, 09:44 AM
  4. Related to Html and Java Script?
    By JackyRock in forum JavaServer Pages: JSP & JSTL
    Replies: 2
    Last Post: February 17th, 2010, 03:10 AM
  5. Help with html tags in java
    By peliukasss in forum Member Introductions
    Replies: 0
    Last Post: February 2nd, 2010, 06:47 AM