2-3 Computer Programming: Programming Problem Using jGrasp and the Software Deve
ID: 664462 • Letter: 2
Question
2-3 Computer Programming: Programming Problem
Using jGrasp and the Software Development Kit, write a program in response to the following prompt:Write a program that prompts the user to enter the mass of a person in kilograms and outputs the equivalent weight in pounds. Output both the mass and the weight rounded to two decimal places. (Note that for standard Earth gravity, 1 kilogram = 2.2 pounds.) Format your output with two decimal places. Your answer should use dialog boxes for the input/output statements.Submit your compiled Java code for this assignment, compress the .java file into a single .zip file.
Explanation / Answer
importjavax.swing.JOptionPane;
public class convert
{
public static void main(String[] args)
{
String input = JOptionPane.showInputDialog(null, "Input a number in Kilograms (Kg) ", "Convert Kgs to Pounds", JOptionPane.INFORMATION_MESSAGE);
double pounds = Double.parseDouble(input);
double kgs = pounds*2.2;
JOptionPane.showMessageDialog(null, pounds + " Kg in give Pounds is " + kgs, "Result", JOptionPane.INFORMATION_MESSAGE);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.