Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

package code; public class AssignmentOne { public static void main(String[]args)

ID: 3747982 • Letter: P

Question

packagecode;

publicclassAssignmentOne {

            publicstaticvoidmain(String[]args) {

                        System.out.println("* * * * * *");

                        System.out.println("*");

                        System.out.println("*");

                        System.out.println("* * * * * *");

                        System.out.println("          *");

                        System.out.println("          *");

                        System.out.println("* * * * * *");

                        System.out.println("*");

                        System.out.println("*");

                        System.out.println("* * * * * *");

                        System.out.println("          *");

                        System.out.println("          *");

                        System.out.println("* * * * * *");

                        System.out.println("*");

                        System.out.println("*");

            }

}

My question is how do I eliminate redundacy to my solution while making it work?

Explanation / Answer

//note:- if you have any query regarding this then comment below. please upvote

public class AssignmentOne {

public static void methodOne()

{

System.out.println("* * * * * *");

}

public static void methodTwo()

{

System.out.println("* *");

}

public static void methodThree()

{

System.out.println(" * *");

}

public static void main(String[] args)

{

methodOne();

methodTwo();

methodOne();

methodThree();

methodOne();

methodTwo();

methodOne();

methodThree();

methodOne();

methodTwo();

}

}