import java.util.Scanner;
class Main {
public static void main(String[] args) {
System.out.println(“Name: “);
System.out.println(“ID: “);
Scanner input=new Scanner(System.in);
double weight,height,BMI;
System.out.print(“Enter weight in Kg: “);
weight=input.nextDouble();
System.out.print(“Enter height in meters: “);
height=input.nextDouble();
BMI=weight/(height*height);
System.out.println(“Your BMI = “+BMI);
}
}
Answer 2
import java.util.Scanner;
class Main {
public static void main(String[] args) {
int x,y,tempt;
Scanner input=new Scanner(System.in);
System.out.print(“Enter X: “);
x=input.nextInt();
System.out.print(“Enter Y: “);
y=input.nextInt();
tempt=x;
x=y;
y=tempt;
System.out.println(“The new value of the variable x is: ” + x);
System.out.println(“The new value of the variable y is: ” + y);
}
}
Answer 3:
public static void main(String[] args) {
System.out.println(“number square cube“);
System.out.printf(“%d %d %dn”, 0, 0*2, 0*3);
System.out.printf(“%d %d %dn”, 1, 1*1, 1*1*1);
System.out.printf(“%d %d %dn”, 2, 2*2, 2*2*2);
System.out.printf(“%d %d %dn”, 3, 3*3, 3*3*3);
System.out.printf(“%d %d %dn”, 4, 4*4, 4*4*4);
System.out.printf(“%d %d %dn”, 5, 5*5, 5*5*5);
System.out.printf(“%d %d %dn”, 6, 6*6, 6*6*6);
System.out.printf(“%d %d %dn”, 7, 7*7, 7*7*7);
System.out.printf(“%d %d %dn”, 8, 8*8, 8*8*8);
System.out.printf(“%d %d %dn”, 9, 9*9, 9*9*9);
System.out.printf(“%d %d %dn”, 10, 10*10, 10*10*10);


0 comments