Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Project Requirements Part I Design ( 30 pts ) : Displaying numbers in a triangul

ID: 3648665 • Letter: P

Question

Project Requirements

Part I Design ( 30 pts ) : Displaying numbers in a triangular pattern:

Write a class (DrawPyramid.java) that displays numbers in a triangular pattern. The class should have have a main method. That is it should be a non executable file.

Then use the following executable program (with the main method), which creates a DrawPyramid object and displays the pyramid.

import java.awt.*;
import javax.swing.*;

public class Pyramid extends JFrame {

public Pyramid() {
DrawPyramid numberPyramid = new DrawPyramid();
add(numberPyramid);
}

public static void main(String[] args) {
Pyramid frame = new Pyramid();
frame.setSize(400, 400);
frame.setTitle("Pyramid");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null); // Center the frame
frame.setVisible(true);
}
}




The number of lines in the display should change to fit the window as the window resizes as follows.




Part II Design ( 30 pts ) : Displaying an image using a titled border,


Write another class(non executable file) ImagePanel.java , which displays an image such as the USA flag as follows(you are free to choose the image ):



Please note that along with the flag, you must use a titled border to define the image such as writing

Explanation / Answer

import java.util.*; public class homeWork6 { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); System.out.println("Enter an interger from 1 to 50:"); int number = keyboard.nextInt(); System.out.println(); if (number < 1) System.out.println("Invalid number: must be at least one."); else if (number > 50) System.out.println("Invalid number: cannot exceed 50."); else // valid input print triangle of asterisks { // print first half int lineCount; int asteriskCount; for (lineCount = 1; lineCount = lineCount; asteriskCount --) System.out.print("*"); } System.out.println(); } //end else }//end main }//end class