Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- public class Asterisks {
- public static void main(String[] args) {
- Scanner kb = new Scanner(System.in);
- System.out.print("Enter the pattern number you would like to run: ");
- int pattern = kb.nextInt();
- int n = 7;
- char space = ' ';
- char ast = '*';
- if (pattern == 1) {
- for (int r = 1; r != n; r++) {
- for (int c = 1; c != r; c++) {
- System.out.print(ast);
- }
- System.out.println();
- }
- }
- else if (pattern == 2) {
- for (int r = 1; r != n; r++) {
- for (int c = 1; c != n-r; c++) {
- System.out.print(space);
- }
- for (int c = n-r; c != n; c++) {
- System.out.print(ast);
- }
- System.out.println();
- }
- }
- else if (pattern == 3) {
- //pattern 3 is patterns 1 and 2 combined
- }
- else {
- System.out.println("Please enter pattern 1 2 or 3");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement