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

Suppose that you are traveling to Greece where they use Kilograms but your brain

ID: 3633060 • Letter: S

Question

Suppose that you are traveling to Greece where they use Kilograms but your brain thinks in pounds, so you want the computer to perform the conversion for you in either direction.
Design a program to:
- Show a menu of choices
- Ask the user which operation they want
- Read in the user response
- Computer and display the result
Based on the user's choice the program calculates a different answer. Use if statements to branch in the code, based on the user's response. Your program should test if the user's answer is one of the supported choices, if not, the user should be told that they have entered an invalid choice.
Write a commented program to convert between pounds and kilograms in either direction.
Give the user two choices: Convert weights:
Pounds to Kilograms (enter 1)
Kilograms to Pounds (enter 2)

Explanation / Answer

import java.util.*;

class Weight{
public static void main (String[] args)throws Exception{
//1 Pounds = 0.45 Kg;
Scanner sc = new Scanner(System.in);
System.out.println("Convert weights:");
System.out.println("Pounds to Kilograms (enter 1)");
System.out.print("Kilograms to Pounds (enter 2)");
int choices = sc.nextInt();
System.out.print("Enter weight: ");
double weight = sc.nextDouble();
if(choices == 1){
double weight *= 0.45;
System.out.printf("%.3f kg",weight);
}else {
double weight /= 0.45;
System.out.printf("%.3f lbs",weight);
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote