java - Creating a Class, and writing methods for the STARS program -
i have assignment code methods of intro "stars" program. have of loops figured out print out designs, writing classes them tripped up. i'm still new programming , i'm sure there lots of silly mistakes in code.
here's document of stars output
public class stars { scanner scan = new scanner(system.in); public int rows; public string part1, part2, part3, part4, part5; public stars(int rows){ } private static string part1(int rows){ (int = 0; < rows; i++) { (int stars = 0; stars < rows; stars++) { system.out.print("*"); } system.out.println(""); } return " "; } private static string part2(int rows){ system.out.println(""); (int = 1; <= rows; i++) { (int star = 1; star <= i; star++) { system.out.print("*"); } system.out.println(""); } return " "; }
public class stars{ public static void main(string[] args){ scanner scan = new scanner(system.in); int rows = scan.nextint(); part1(rows); part2(rows) } private static string part1(int rows){ (int = 0; < rows; i++) { (int stars = 0; stars < rows; stars++) { system.out.print("*"); } system.out.println(""); } return " "; } private static string part2(int rows){ system.out.println(""); (int = 1; <= rows; i++) { (int star = 1; star <= i; star++) { system.out.print("*"); } system.out.println(""); } return " "; } }
you don't need return type methods part1 , part2 because apparently returning empty string.
Comments
Post a Comment