Sample Solution from
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Chapter 1
Problem 1.1PE
Try another sample solution
Textbook Problem

(Display three messages) Write a program that displays Welcome to Java, Welcome to Computer Science, and Programming is fun.

Expert Solution
Program Plan Intro

Display Three Messages

Program plan:

  • Include the header file.
  • Print the messages on output window using print statement.
  • Display the output.
Program Description Answer

The basic Java program to display three messages on the output window.

Explanation of Solution

Program:

// Class definition

public class threeMessages {

// Main method

public static void main(String[] args) {

// Display the three messages

System.out.println("Welcome to Java");

System.out.println("Welcome to Computer Science");

System.out.println("Programming is fun");

}

}

Sample Output

Welcome to Java

Welcome to Computer Science

Programming is fun

Not sold yet?Try another sample solution