subject

A. Download the attached "RationalNumber. java" b. Background: a rational number represents a fraction, e. g. 3 / 5. Here, 3 is the numerator, and 5 is the denominator; both are integers (can be either positive or negative). The denominator cannot be 0.
c. Implement two constructors: public RationalNumber(int numerator, int denominator) It constructs a new rational number. You can assume that the denominator will never be 0. public RationalNumber() It constructs a new rational number to represent 0 / 1
d. Implement the two accessors: public int getDenominator() It returns this rational number’s denominator. For example, for 3 / 5, it returns 5. public int getNumerator() It returns this rational number’s numerator. For example, for 3 / 5, it returns 3.
e. Implement the toString method: public String toString() It returns a String representation of this rational number, such as "3/5". If the denominator is 1, omit it. For example, for 4 / 1, it returns "4". If the numerator is 0, omit denominator. For example, for 0 / 8, it returns "0". You do NOT need to worry about reduced form (e. g. for 3 / 6, just returns "3/6" is good enough, no need to return "1/2"), or negative numbers (e. g. for 3 / -5, just returns "3/-5" is enough, no need to return "-3/5").
f. Implement the methods to add, subtract, multiply and divide another rational number. Here is the "method signature" for add: public RationalNumber add(RationalNumber numberToAdd) In the method, you should compute and return the result for the addition. For example, if r1 is 3 / 5, r2 is -1 / 5, r1.add(r2) should return a value of 2 / 5. Whether you choose to update the value of r1 is your choice -- in other words, it won’t affect your grade, as long as the value returned from the method is correct. Again, you don’t need to worry about reduced form. Please make sure NOT to change the "method signatures" in the original file, otherwise you will receive significant penalty.
g. For this assignment, you are limited to the language features in Chapters 1 through 8 of the textbook. Arrays are allowed
h. Remember, your program will be graded both on "external correctness" and "internal design and style" (whether your source code follows the style guide)
i. Submit the final "RationalNumber. java" file (DO NOT change the file name)
this is the initial rational number. java file
// Student Name
public class RationalNumber {
// TODO: implement the following methods
// public RationalNumber(int numerator, int denominator) {
// } // public RationalNumber() {
// }
// public int getDenominator() {
// }
// public int getNumerator() {
// }
/ public String toString() {
// }
// public RationalNumber add(RationalNumber other) {
// }
// public RationalNumber subtract(RationalNumber other) {
// }
// public RationalNumber multiply(RationalNumber other) {
// }
// public RationalNumber divide(RationalNumber other) {
// }
}

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 18:30, emojigirl2824
Word vocabulary words: print, proofread, status line, graphics, font effects, left margin, justification, line spacing, copy/paste, data. review words: font point, bold, save, center, error. fill in the correct word for the definition and then transfer the letters to the appropriate spot by number. some numbers will be found multiple times. you will end up with a quotation about…… what else? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 k 16 17 18 19 20 21 22 23 24 25 8 27 28 29 w 31 32 k 34 35 36 w h 39 40 41 42 8 44 45 46 47 48 49 50 51 52 53 54 55 .1. a software function that records keystrokes on a disk or drive so information can be 5 4 52 9 later retrieved. p n 2. to produce a paper copy of information. 10 7 12u n 3. a display that shows the location of the cursor, pages, etc. 45 46 18 27 36 20 42p4. pictures or images, located in clip art or other files. 6 24 44 28 34 49 555. any mis-stroke of a key. 47 41 48 2 10 n6. allows major changes to the font such as shadow, emboss, etc. 21 25 46 35 23 21 29 14 22 17 n7. a feature that centers lines of text horizontally. 49 53 46 9 51 p8. size of the font 31 16 22 b l 9. a feature that prints designated text darker than the rest to add emphasis. 32 3 . p10. to compare copy on a display screen or printout to the original 24 39 25 23 54 9 50 3 and correct errors. j un 11. a feature that allows text to be aligned at the left 11 12 7 21 16 49 40 46 34 2 and right margins. leftn 12. amount of blank space on the left side of the paper. 8 18 41 6 34 linen 13. number of blank lines between lines of text. 17 4 49 13 1914. any information inputted into the computer. 3 4 46 44 p /p15. feature that duplicates text from one location and places it in another.
Answers: 2
image
Computers and Technology, 24.06.2019 00:30, rustjallison9928
Asecurity policy is a a. set of guidlines b. set of transmission protocols c. written document d. set of rules based on standards and guidelines
Answers: 2
image
Computers and Technology, 24.06.2019 09:50, ira51
Suppose you are an ad-serving company and you maintain a log of cookie data for ads you serve to the web pages for a particular vendor (say amazon). a. how can you use this data to determine which are the best ads? b. how can you use this data to determine which are the best ad formats? c. how could you records of past ads and ad clicks to determine which ads to send to a given ip address? d. how could you use this data to determine how well the technique you used in your answer to part c was working? e. how could you use this data to determine that a given ip address is used by more than one person? f. how does having this data give you a competitive advantage vis-à-vis other ad-serving companies?
Answers: 2
image
Computers and Technology, 24.06.2019 13:50, jaystarr9395
Write a program that performs a simple n-body simulation, called "jumping leprechauns." this simulation involves n leprechauns, numberd 1 to n. it maintains a gold value g_i for each leprechaun i, which begins with each leprechaun starting out with a million dollars worth of gold, that is, g_i = 1000000 for each i = 1,. in addition, the simulation also maintains, for each leprachaun, i, a place on the horizon, which is represented as a double-precision floating point number, x_i. in each iteration of the simulation, the simulation processes the leprachauns in order. processing a leprachaun i during its iteration begins by computing a new place on the horizon for i, which is determined by the assignment:
Answers: 3
You know the right answer?
A. Download the attached "RationalNumber. java" b. Background: a rational number represents a fract...

Questions in other subjects:

Konu
Mathematics, 12.04.2021 21:00