Answered step by step
Verified Expert Solution
Question
1 Approved Answer
8 : 2 4 7 7 Back The Last Program of Spring 2 4 . pptx Switch To Dark Mode Programming Exercise: Pattern Printing Objective:
:
Back The Last Program of Spring pptx
Switch To Dark Mode
Programming Exercise: Pattern Printing
Objective:
Create a Java program that prints patterns of the letters X and Y Your task is to design a class named 'PatternPrinter' that can print multiple instances of these patterns. You will then use this class in your 'main method to print the specified number of X and Y patterns.
Requirements:
PatternPrinter Class:
The 'PatternPrinter' class should have two methods: 'printXint size and 'printYint size
Both methods should accept an integer 'size' which determines the size of the pattern to be printed. For simplicity, assume that 'size' is always an odd number.
The 'printX' method should print an X shape, with each arm of the X touching the corners of a square of height and width 'size'.
The printY method should print a Y shape, with the top arms of the Y meeting at the middle of the pattern and extending down vertically for the remaining half. Main Method:
In your 'main' method, create an instance of the 'PatternPrinter' class.
Using this instance, print two X patterns and three Y patterns.
Each pattern should be separated by a blank line for clear visibility.
Content credits to ChatGPT
Example output for size
Instructions
Write your PatternPrinter class with the required methods.
In the main method of another class, create an instance of PatternPrinter and use it to print the patterns as specified.
Ensure your code is wellcommented to explain the logic you used for each part of the pattern.
Consider the readability and efficiency of your code.
Submission:
Submit your java files containing the classes. Make sure your program runs correctly before submission.
Screenshot of output
Dashboard
Dashboard
Calendar
Calendar
To Do
Notifications
InboxPlease write in java and please annotate to show understanding
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started