Create a program that will read the values of A and B. Compare the two values of A & B then print which of the values is higher including the remark "Higher".
SOLUTION CODE
package com.company;
import java.util.*;
public class Main{
public static void main(String[] args) {
//Create a program that will read the values of A and B. Compare the
// two values of A & B then print which of the values is higher including
// the remark "Higher".
Scanner sc = new Scanner(System.in);
System.out.print("Enter value for A: ");
double A = sc.nextDouble();
System.out.print("Enter value for B: ");
double B = sc.nextDouble();
//compare the two valiues
if(A>B)
{
System.out.println("The value of A is Higher than value of B");
}
else if(B>A)
{
System.out.println("The value of B is Higher than value of A");
}
else
{
System.out.println("The value of A and B are equal");
}
}
}
Comments
Leave a comment