Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

AP Computer Science A Lab #13 -- Writing Classes Learning Objective Using Java, create a class which will be used to create objects. Lab Description

image text in transcribed

AP Computer Science A Lab \#13 -- Writing Classes Learning Objective Using Java, create a class which will be used to create objects. Lab Description Create a Java class whose instance variables will represent a fraction's numerator and denominator as integers. The methods of the program will provide for fraction arithmetic according to the following rules, given that n1/d1 is the first fraction and n2/d2 is the second fraction. \begin{tabular}{|l|l|} \hline addition & d1n1+d2n2=d1d2n1d2+n2d1 \\ \hline subtraction & d1n1d2n2=d1d2n1d2n2d1 \\ \hline multiplication & d1n1d2n2=d1d2n1n2 \\ \hlined1n1/d2n2=d1n2n1d2 \\ \hline division & \\ \hline \end{tabular} Provide a constructor method which will accept the numerator and denominator as parameters. Define accessor methods to obtain the numerator and denominator. Use the rules of fraction arithmetic provided above to define methods add (), sub(),mult(), and div(). Each of these methods expects a fraction object as a parameter. The object passed via parameter is considered the right operand of the operation. The left operand is the receiver object (i.e., the one containing the instance variables for the numerator and denominator). Each arithmetic method builds a new instance of the Fraction class with the results of its calculation and returns it as the method's value. Your Fraction class must function with the way it is used in the main method provided. IPO Chart Complete an IPO chart for this lab. You can copy a blank IPO chart into your Google Drive here. Use variable names which follow Java naming rules and conventions, which we have discussed in class. Once you have completed your IPO chart, you may begin coding

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

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

What do you understand by Mendeleev's periodic table

Answered: 1 week ago