Question: 6. (20 points) A Gaussian integer is a number of the form a + bi, where a and b are integers, and i is the

 6. (20 points) A Gaussian integer is a number of the
form a + bi, where a and b are integers, and i

6. (20 points) A Gaussian integer is a number of the form a + bi, where a and b are integers, and i is the imaginary constant representing the square root of -1. In such an expression, a is called the "real part" and b is called the "imaginary part" of the Gaussian integer. To multiply two numbers of this form, you use the distributive property and the fact that ? = -1. To simplify this for you, I will just give you the formula: (a + b) (c+di) = (ac - bd) + (ad + bc)i Write a program which asks the user to input in four integers, representing two Gaus- sian Integers r and y. Output each Gaussian Integer on its own line, and then output their product. You will implmeent this in a modular way, as follows: (a) (12 points) First implement the following helper methods: getNumber outputs prompt and gets input from the user. If that input is not an integer, it should output error and try to get input again (repeatedly; this method should continue trying to get input from the user until it actually gets input), and then returns the input. realPartMultiply takes in four parameters: the real and imaginary parts of a Gaussian Integer x, and the real and imaginary parts of a Gaussian integer y, and returns the real part of the product xy. That is, given a+bi and c+di, it returns ac- - bd. imagPart Multiply takes in four parameters: the real and imagirlary parts of a Gaussian integer x, and the real and imaginary parts of a Gaussian integer y, and returns the imaginary part of the product xy. That is, given a + bi and c+di, it returns ad + bc. displayNumber takes in two paramters: a real part and an imaginary part, and returns a String which contains the number written in standard form. That is, given a and b, it returns the String "a + bi" public static int getNumber (Scanner scanner, String prompt, String error) { } public static int realPartMultiply(int realx, int imagx, int realy, int imagY) { } public static int imagPartMultiply(int realx, int imagx, int realy, int imagY) { } public static String displayNumber(int real, int imag) { }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!