help today plz:(

help today plz:(

write a program that promptes the user to enter the weight of a package in pounds, and then outputs the weight of the backage in to kilograms
(one kilogram is approximately, 2.2 pounds)?
but i don't use "for" and import java.text.*;
View Answers

December 24, 2009 at 10:45 AM

Hi Friend,

Try the following code:

import java.util.*;
class Weight{
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.println("Enter weight in pounds: ");
double w=input.nextDouble();
//2.2 pounds is equal to 1 kg.
double value=1/2.2;
double weightInKg=w*value;
System.out.println("Weight in Kg: "+weightInKg);
}
}

Thanks









Related Tutorials/Questions & Answers:

Ads