Question
Provide PHOTO ANSWERS: the UML class diagram for your Fraction class for the code, and the structure chart for the client class package com.mycompany.fraction; import
Provide PHOTO ANSWERS: the UML class diagram for your Fraction class for the code, and the structure chart for the client class
package com.mycompany.fraction;
import java.util.Scanner; class Fraction {
private int numerator; private int denominator; @Override public String toString() { return numerator+"/"+denominator; } }
public class TestFraction { public static void main(String args[]){
Scanner scan = new Scanner(System.in); int num, denom; while(true){ System.out.println("Enter the numerator: "); num = scan.nextInt(); if(num<0) break; System.out.println("Enter the denominator: "); denom = scan.nextInt(); while(denom==0){ System.out.println("Denominator cannot be 0...Try again..."); System.out.println("Enter the denominator: "); denom = scan.nextInt(); } if(denom<0) { num = (-1)*num; denom = (-1)*denom; }
Fraction f = new Fraction(); f.numerator = num; f.denominator = denom;
System.out.println("Entered Fraction: "+f); } }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started