Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Programming problem for weight conversion: Write a program that prompts the user

ID: 3557220 • Letter: P

Question

Programming problem for weight conversion:

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. (Conversion: 1 kilogram = 2.2 pounds.) Format your output with two decimal places. Use dialog boxes for the input/output statements.

This is what I came up with and received six errors that I am having trouble correcting, just need guidance in right direction:

import javax.swing.joptionpane;

public class MassofaPersonProgram
{
   public static void main(string[] args)
   {
      string massinkilograms;
      string inputstr;
      string outputstr;
    
      double kilograms;
      for (int i = 1);
    
      inputstr = joptionpane.showinputdialog("Enter mass in kilograms");
      kilograms = double.parsedouble(inputstr);
      string.format = (i * 2.20);
    
      outputstr = "Equivalent weight in pounds:" + string.format("%.2f, pounds");
      joptionpane.showmessagedialog(null, outputstr,"Weight in Pounds",joptionpane.INFORMATION_MESSAGE);
      system.exit(0);
   }
}
           

Explanation / Answer

import java.text.DecimalFormat;

import javax.swing.JOptionPane;

?

public class MassofaPersonProgram

{

public static void main(String[] args)

{

String massinkilograms;

String inputstr;

String outputstr;

double kilograms;

inputstr = JOptionPane.showInputDialog("Enter mass in kilograms");

kilograms = Double.parseDouble(inputstr);

outputstr = new DecimalFormat("##.##").format(kilograms* 2.20);

JOptionPane.showMessageDialog(null, outputstr,"Weight in Pounds",JOptionPane.INFORMATION_MESSAGE);

System.exit(0);

}

}