Question: can some fix the code so that it can do this output. because its doing this port statements for Scanner class ret java.util.Scanner; Lic class

 can some fix the code so that it can do this

output. because its doing this port statements for Scanner class ret java.util.Scanner;

Lic class FractionDemo \{ public static void main(String[] args) \{ // Variables

for two fractions int num1, num2, den1, den2; 1/ Create Scanner object

to read keyboard input Scanner keyboard = new Scanner(System. in); // Get

can some fix the code so that it can do this output. because its doing this

port statements for Scanner class ret java.util.Scanner; Lic class FractionDemo \{ public static void main(String[] args) \{ // Variables for two fractions int num1, num2, den1, den2; 1/ Create Scanner object to read keyboard input Scanner keyboard = new Scanner(System. in); // Get integers for f1 numerator and denominator System.out.print("Enter the numerator of the first fraction: "); num1 = keyboard . nextInt () ; System.out.print("Enter the denominator of the first fraction: "); den1 = keyboard . nextInt () ; 1/ Get integers for f2 numerator and denominator System.out.print("Enter the numerator of the second fraction: "); num2 = keyboard . nextInt () ; System.out.print("Enter the denominator of the second fraction: "); den2= keyboard nextInt(); 1/ Check if denominator is zero for f1 and reset it to 1 if (den1=0){ System.out.println("For Fraction 1: ("+ num1 + "/" + den1 + "):"); System.out.println("Denominator cannot be zero; denominator value is being reset to one. The Fraction is now: (" + num1 + "/1)"); den1=1 3 1/ Check if denominator is zero for f2 and reset it to 1 if (den2=0){ System.out.println("For Fraction 2: ("+num2+"/"+den2+"):"); System.out.println("Denominator cannot be zero; denominator value is being reset to one. InThe Fraction is now: (" + num2 + "/ 1 )"); System.out.println("Denominator cannot be zero; denominator value is being reset to one. InThe Fraction is now: (" + num2 + " /1 )"); ...-jgRASP exec: java FractionDemo Enter the numerator of the first fraction: 1 Enter the denominator of the first fraction: 3 Enter the numerator of the second fraction: 3 Enter the denominator of the second fraction: 0 For Fraction 2: (3/) : Denominator cannot be zero; denominator value is being reset to one. The fraction is now: (3/1) f(1)==(1/3) f(2)==(3/1) (1/3)(3/1)==(3/3) -.-jGRASP: operation complete. Lab13 Program output when user attempts to assign zero to denominator Enter the numerator of the first fraction: 1 Enter the denominator of the first fraction: 3 Enter the numerator of the second fraction: 3 Enter the denominator of the second fraction: 0 For Fraction: (3/) : Denominator cannot be zero; denominator value is being reset to one The fraction is now: ( 3 ) f1==(1/3) f2==(3) (1/3)(3)==(33)

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!