CSC 120

Week 13


Reading Assignment:

Read Chapter 8

Programming Assignments:

Here are the classes MiniCalc and DoMath we examined in class: MiniCalc.java DoMath.java

  1. Add a Multiply and a Divide button to the interface. Modify the DoMath class to make these buttons functional. Test your program to verify your modifications. What happens if you divide by zero? What happens if you divide zero by zero?
  2. Add a Clear and an Exit button to the interface. Modify the DoMath class to make these button functional. Hint: use the following code fragment before try-catch
       if (e.getActionCommand().equals("Exit"))
           System.exit(0);
       if  (e.getActionCommand().equals("Clear")){
         output.setText(" ");
         inputOne.setText(" ");
         inputTwo.setText(" ");
         return;
       } 
    
    
  3. Small stand-alone java programs can often be converted to applets with ease. Here are the files for an applet version of the MiniCalc program: MiniCalcApplet.java MiniCalcApplet.html
    Compile the files MiniCalcApplet.java and DoMath.java. To see your applet, just run the MiniCalcApplet.html file. You should modify the applet version MiniCalcApplet as described above so that you can have a four-function calculator on your web page. You are welcome to change the .html file as you please to showcase your knowledge of HTML.