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();
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.