008-001-008

void Method: Greeting Message Display

Medium

Problem Description

void method: Greeting Message Display

In this problem, you will create a program that defines three void methods in a Greeter class for displaying time-based greetings and calls them in sequence from a Main class to display the results to standard output.

Learning Objective: Understand definition and invocation of void methods without return values

Overview

Create methods that display greeting messages based on time of day. void methods perform actions (in this case, screen output) without returning values.

Specifications

Greeter Class

Define three void methods:

  • void morning(): Display "Good morning!"
  • void afternoon(): Display "Good afternoon!"
  • void evening(): Display "Good evening!"

Main Class

  • Create Greeter instance
  • Call the three methods in sequence

Output Format

Good morning!
Good afternoon!
Good evening!

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up