009-002-011
Public Classes and Files
Medium
Problem Description
Public Classes and Files
In this problem, you will create a program that defines a printGreeting(String name) method in the MessagePrinter class, reads a name using Scanner from the Main class, creates an instance, and calls the method to display the result to standard output.
Learning Objective: Understand the relationship between public classes and file names
Overview
Create a public class and understand the correspondence with file names.
Specifications
- Define
public void printGreeting(String name)method inMessagePrinterclass - Read a name (1 line) using Scanner in the
Mainclass - Create a
MessagePrinterinstance and call the method
Input
A string representing a name (1 line)
Output Format
Hello, <name>! From MessagePrinter.
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