Quick actions

cmd+k|ctrl+k

Navigation

Languages

Week1Mock1MCQ14

Snippet info

Language

Java

Visibility

public

Author

masterhun

Created

2024-04-02T02:23:12.813128Z

Updated

2024-04-02T02:36:37.047904Z

public class Main {
    
    public static void main(String[] args) {
        
        // Harbor, Week 1, Mock 1, PR_PracticeTest_1.pdf
        
        // AP CS A 
        
        // MCQ 14 
        
        String space = " ";
        String symbol = "*";
        int num = 5;
        for (int i = 1; i <= num; i++)
        {
            System.out.print(symbol);
        }
        System.out.print("\n");
        for (int i = 1; i <= num; i++)
        {
            for (int j = num - i; j > 0; j--)
            {
                System.out.print(space);
            }
            System.out.print(symbol);
            // The original code in the mock test 
            // is missing the line below.
            // With the line of code below, 
            // this code produces a "Z".
            System.out.print("\n");
        }
        for (int i = 1; i <= num; i++)
        {
            System.out.print(symbol);
        }
        
        
        // Output: [Asterisks form the letter "Z".]
        
    }
}
INFO