-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweightconversion.java
More file actions
36 lines (30 loc) · 1.01 KB
/
weightconversion.java
File metadata and controls
36 lines (30 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.util.Scanner;
public class weightconversion {
public static void main(String[] args) {
//weight conversion program//
Scanner sc = new Scanner(System.in);
double weight;
double newweight;
int choice;
System.out.println("weight conversion program");
System.out.println("1:convert weight from lbs to kg");
System.out.println("2:convert weight from kg to lbs");
System.out.println("choose an option");
choice= sc.nextInt();
if(choice==1){
System.out.println("enter weight in lbs");
weight= sc.nextDouble();
newweight= weight*0.453592;
System.out.println("weight in kg is "+ newweight);
}
else if ( choice==2){
System.out.println("enter weight in kg");
weight = sc.nextDouble();
newweight= weight*2.20462;
System.out.println("weight in lbs is" +newweight);
}
else{
System.out.println("invalid choice");
}
}
}