Part I:

Write a Java driver class (program) that will use the Die class provided in the text book. The program will prompt user for a number, say aNum. The program then will roll two Die objects for aNum times and find out how many times the sum of face value of the 2 objects is 7. The program should give a clear output describe what the program is doing and what is the result. Name your driver class as YourFirstNameYourLastNameRollTwoDice.java

Part II:

Write an application that displays a frame containing two panels. The first (or top) panel should contain your photo and the second panel should contain you firstName lastName a slogan. An example showing my picture is followed. See image.

How to do it?

  • Get a digital photo of yours and open it in the Accessories/Paint program. Click the resize button to resize your picture to the desired size (use pixels). Write the width and height down so that you can set your panel dimension to the right size.
  • Download the PushCounter.java program and save a copy as AboutMeYourLastName.java to your flash drive. In my case, my filename should be AboutMeMayHou.java. Change to the class name to the same as the file name.
  • Download the PushCounterPanel.java and save a copy as YourFirstNameYourLastNamePanel.java. In my case, it is MayHouPanel.java. Change the class name and the constructors name to the same as the filename.
  • Change the following line in the AboutMeYourLastName.java: frame.getContentPane().add(new PushCounterPanel()); to frame.getContentPane().add(new MayHouPanel());
  • Declare 2 JPanel, 3 JLabel objects before the constructor in MayHouPanel.java
  • Declare 1 ImageIcon object in MayHouPanel.java (ref. LabelDemo.java in chapter 3)
  • In the MayHouPanel constructor:
    • Instantiate the icon object with the digital file name as the following: Icon = new ImageIcon(xxx.jpg); // remember: the picture should be stored in the same dir
    • Instantiate the label1 with the icon: label1 = new JLabel(icon);
    • Instantiate the top panel and add the label1 to it; set its dimension, background color.
    • Instantiate the label2 with the text of your name: label1 = new JLabel(May Hou - );
    • Create a new Font object (f) and set the size to at least 20 with your choice of font style and name.
    • Set the label2 font to f: label2.setFont(f);
    • Set font color: label2. setForeground (.); // give a nice color in the parenthesis check Color class in the system library for color names
    • Instantiate the label3 with the text of your slogan: label1 = new JLabel(The Super Mom );
    • Create a new Font object (f) and set the size to at least 20 with your choice of font style and name.
    • Set the label3 font to f: label3.setFont(f);
    • Set font color: label3. setForeground (.); // give a nice color in the parenthesis check Color class in the system library for color names
    • Instantiate the bottom panel and add the label2 and label3 to it; set its dimension, background color.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.