in Education by
WAP in java to input 2 numbers from user and print their difference (Always Positive). Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
Answer: import java.util.Scanner; public class positive_difference { public static void main(String args[]){ Scanner ob = new Scanner(System.in); int input_1, input_2, diff; System.out.println(“Enter the 1st Number “); input_1 = ob.nextInt(); System.out.println(“Enter the 2nd Number “); input_2 = ob.nextInt(); diff = input_1 – input_2; if (diff<0) diff = diff * (-1); System.out.println(“Their difference = “+diff); } }

Related questions

0 votes
    WAP in java to input 3 numbers from user and print the largest no. among them using nested if. Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
0 votes
    WAP to obtain 2 numbers from the user and then display the maximum number out of these 2 numbers and also display ... . (5 Points) Select the correct answer from above options...
asked Dec 28, 2021 in Education by JackTerrance
0 votes
    wap to obtain 2 numbers from the user and then display the maximum number out of those 2 numbers and also display ... from the number?n Select the correct answer from above options...
asked Dec 25, 2021 in Education by JackTerrance
0 votes
    2 Write an algorithm to input two numbers and find their sum and difference Select the correct answer from above options...
asked Nov 28, 2021 in Education by JackTerrance
0 votes
    java program to input any string then print each word along with their length Select the correct answer from above options...
asked Dec 31, 2021 in Education by JackTerrance
0 votes
    Wap in Java to print a pascal triangle in simple language. Please explain the logic Select the correct answer from above options...
asked Dec 22, 2021 in Education by JackTerrance
0 votes
    write a program in python to obtain 3 numbers and print their sum. Select the correct answer from above options...
asked Nov 29, 2021 in Education by JackTerrance
0 votes
    WAP to print the result based on the user's choice; Choices: 1. Enter 1 to print the Square root of any ... answer fast it's urgent Select the correct answer from above options...
asked Dec 30, 2021 in Education by JackTerrance
0 votes
    write a program to input three integers and find the difference between their sum and difference Select the correct answer from above options...
asked Dec 20, 2021 in Education by JackTerrance
0 votes
    Write a python program to print first n(entered by user) even natural numbers. Select the correct answer from above options...
asked Dec 25, 2021 in Education by JackTerrance
0 votes
    Assembly language porgram to find positive or negative and take values from user Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
0 votes
    Write a program in JAVA to input a sentence reverse every word and print . Please answer someone. Select the correct answer from above options...
asked Dec 13, 2021 in Education by JackTerrance
0 votes
    write a program in Java to input a number and print if it is a special number or not. do this program using ... nested and while loop . Select the correct answer from above options...
asked Dec 1, 2021 in Education by JackTerrance
0 votes
    How to write a program in JAVA to print the sum of ASCII values of a particular word input ? Select the correct answer from above options...
asked Dec 28, 2021 in Education by JackTerrance
...