Answered step by step
Verified Expert Solution
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
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
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