Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions

Question

3. What obstacles interfere with eff ective listening?

Answered: 1 week ago