Question: Please use Java Problem 3: Pyramid (Pyramid.java) Description: Write a Java class named Pyramid that prompts the user to enter an integer from 1 to
Problem 3: Pyramid (Pyramid.java) Description: Write a Java class named Pyramid that prompts the user to enter an integer from 1 to 15 and displays a pyramid, as shown in the following sample run: Enter the number of lines: 7 1 2 1 2 3 2 1 2 3 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5 6 5 4 3 2 1 2 3 4 5 6 7 6 5 4 3 2 1 2 3 4 5 6 7 Please implement your codes using for-loop and while-loop respectively. Outputs: $ java Pyramid Will ouptut the above figure twice (one for for-loop and one for while-loop). Problem 4. Longest Common Prefix (LongestCommonPrefix.java) Description Write a Java class named LongestCommonPrefix that prompts the user to enter two strings (the strings can be empty), and display the longest common prefix of the two strings. Outputs: $java LongestCommonPrefix Enter the first string: Welcome to Java Enter the second string: Welcome to C++ The longest common prefix is: Welcome to Sjava LongestCommonPrefix Enter the first string: Beijing Enter the second string: Boston The longest common prefix is: B
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
