Answer to Question #271121 in Java | JSP | JSF for Bjoy

Question #271121

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".

1
Expert's answer
2021-11-26T07:08:31-0500


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");
        }

    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS