Question: Java Please. Declare double variables num1, den1, num2, and den2, and read each variable from input in that order. Find the difference of the fractions

Java Please.

Declare double variables num1, den1, num2, and den2, and read each variable from input in that order. Find the difference of the fractions num1/den1 and num2/den2 and assign the result to diffFractions. The calculation is: Ex: If the input is 3.0 1.0 5.0 1.5, the output is: -0.33

Note: Assume that den1 and den2 will not be 0.

import java.util.Scanner;

public class DifferenceCalculator { public static void main(String[] args) { Scanner scnr = new Scanner(System.in);

double diffFractions;

//your code goes here

System.out.printf("%.2f", diffFractions);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!