Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


fajer
help today plz:(
1 Answer(s)      4 years and 7 months ago
Posted in : Java Interview Questions


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.*;

Advertisement
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:
 

 

 

DMCA.com