1. Create a new file called Fraction.java 2. In this file, create a class Fraction.  a. This class should have 2 attributes, declare it, don’t forget those

1. Create a new file called Fraction.java

2. In this file, create a class Fraction. 

a. This class should have 2 attributes, declare it, don’t forget those fields/attributes need to be private

b. Create 2 constructors,

i. One constructor without any parameter. This constructor will initialize the first attribute to 0 and the second to 1.

ii. The second constructor will have 2 parameters that will initialize the 2 attributes of the Fraction class.

c. Create a getter and a setter for each private fields.

d. Create 4 methods, addition, subtract, multiply, divide.  Don’t forget to declare those methods public so every objects can use  them. Since those methods needs to be called by an instance of the class  Fraction, what do those methods need to achieve the  addition/subtraction/multiplication/division of TWO fractions. The 4  methods need to return a brand NEW fraction result of the addition/subtraction/multiplication/division of the 2 fractions. a/b + c/d = a/b – c/d = a/b * c/d = a/b / c/d 

e. Create a method properFraction,  that has no parameter. This method will return a whole number and  modify the original Fraction to a proper Fraction. For instance:

   Fraction f1 = new Fraction(7,2);// f1-> 7/2   System.out.print(f1.properFraction());// output: 3, f1->1/2   Fraction f2 = new Fraction(2,5); // f2-> 2/5   System.out.print(f2.properFraction());// output: 0, f1->2/5

f. Create a method toString that will return a String made with the 2 attributes with the following format “4/3”.

3.  In the Main.java file, create 3 Fractions with different values. Test  the addition/subtraction/multiplication/division and the properFractions  methods.

Share This Post

Email
WhatsApp
Facebook
Twitter
LinkedIn
Pinterest
Reddit

Order a Similar Paper and get 15% Discount on your First Order

Related Questions

Accounting: Business and finance: computerscience: Economics: Marketing: Social Science Am a professional academic writer, content creator and, copywriter

Accounting: Business and finance: computerscience: Economics: Marketing: Social Science Am a professional academic writer, content creator and, copywriter with 7 years of research based experience. My passion for research, writing, and editin g makes me the perfect professional for varying topics in Studydaddy. I understand the value of detailed research

BYOD Registration Form Resources To complete this project, you may need to review instructions on how to take a screenshot.   Locate System

BYOD Registration Form Resources To complete this project, you may need to review instructions on how to take a screenshot.   Locate System Information Review this resource to check how to locate your system information.   Template Use the BYOD Ingest Form Template to complete the project. Delete the instructional text from the template before you submit.    2024 University of

Topic: Computer ScienceDistributed Database Management Systems (DDBMS), is the next generation of Database Management Systems, where the data is stored at

Topic: Computer ScienceDistributed Database Management Systems (DDBMS), is the next generation of Database Management Systems, where the data is stored at several geographical locations, but from the user or application perspective, it is still one Database. These are the advantages of this paradigm: enlarged availability and reliability of data, and

In this part, you are asked to explore and/or investigate distributed database management system (DDBMS). You can either explore the main concepts or

In this part, you are asked to explore and/or investigate distributed database management system (DDBMS). You can either explore the main concepts or technical challenges of DDBMS in general (without directly specifying a certain DBMS) or you can research a specific DBMS and present how it manages different aspects of distribution. Your exploration or

**Tutorial: Introduction to Graph Theory** **Category:** Computer Science **Details:** Graph theory is a foundational concept in computer science and

**Tutorial: Introduction to Graph Theory** **Category:** Computer Science **Details:** Graph theory is a foundational concept in computer science and mathematics, focusing on the study of graphs, which are structures consisting of nodes (vertices) and edges (connections between nodes). This tutorial provides a comprehensive introduction to graph theory, covering essential topics

Tunneling in VPN refers to securely transmitting data across the internet by encapsulating it within another packet, resulting in a “tunnel.” This process

Tunneling in VPN refers to securely transmitting data across the internet by encapsulating it within another packet, resulting in a “tunnel.” This process ensures privacy and security by preventing unauthorized access to data during transmission. Common tunneling protocols include PPTP, L2TP, and OpenVPN, which help to ensure data confidentiality and