Assessment weight : 3% |
Due : Week 5 |
English - metric conversion program. Enter the weight in pounds and ounces. Pounds:Use constants in doing the conversion. Thus, you should include the following statements in your program:Ounces: That's grams, or kilograms.
final int OZS_PER_LB = 16; final int GRAM_PER_OZ = 28; final float KG_PER_GRAM = 0.001f;
/* 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" );
}
}
Chose either console I/O or GUI dialog box when you write your program.