CE00371-1 INTRODUCTION TO SOFTWARE DEVELOPMENT


Lab/Tutorial 3

Assessment weight : 3%

Due : Week 5

Part A Programming exercises.

  1. Under Windows environment, write a Java program to print your name, and student number

  2. Using Windows Java SDK and CirArea.java as reference, modify the program to write a English-metric conversion program that converts pounds and ounces to kilograms. Sample input/output of the program can be as follows:
    	English - metric conversion program.
    	Enter the weight in pounds and ounces.
    	Pounds: 
    	Ounces: 
    
    	That's  grams, or  kilograms.
    
    Use constants in doing the conversion. Thus, you should include the following statements in your program:
     	final int OZS_PER_LB = 16;
    	final int GRAM_PER_OZ = 28;
    	final float KG_PER_GRAM = 0.001f;
    
  3. Given the following Java Program
    /*      Program CirAreaUsingDialogBox.java              **
     **                                                     **
     ** This program asks the user to input a               **
     ** number for the radius of a circle.  The program     **
     ** then calculates the area of the circle.             */
    
    import javax.swing.JOptionPane;
    
    public class CirAreaUsingDialogBox  {
        public static void main(String[] arg) {
           float area ;
           int r  ;
           final float pi=3.14f ;
    
           String rString;  // string input by user
    
           rString = JOptionPane.showInputDialog( "Please enter radius in whole number: " );
           r = Integer.parseInt(rString);
    
           area = pi * r * r ;
    
           JOptionPane.showMessageDialog( null, "The radius you provided was " + r + 
                                                " feet and  the area is about " + 
                                                area + " sq feet" );
         }
    } 
    
  4. Enter, compile and run the above program using Eclipse.

  5. Based on the above program and the metric conversion program that you have written for Q2, modify the metric conversion program to use Dialog Box for input/output.

  6. Based on the algorithm given in Quiz 1 Answer:

    Chose either console I/O or GUI dialog box when you write your program.

Part B Create a Web page to publish your answers.

  1. Use MS Notepad or some other simple text editor to create a web page that will look similar to this image, and save in a file named "Lab3Ans.html". Do not use an HTML authoring tool or Microsoft Word to do this exercise. As the final step, add a link for Lab3Ans.html to your Web page that you created in Lab1.