Java code that needs to be coded-complex number class

Assignment Help JAVA Programming
Reference no: EM13286806

Just a Java Code that needs to be coded. Your given the design, just needs the methods and such to be fixed. This is for a Complex Number class.

/**

* ComplexNumber models a complex number expressed

* in rectangular form (real and imaginary parts).

* It is an <em>immutable</em> object.

*

*/

public class ComplexNumber {

//Instance variable declarations

/**

* Construct a ComplexNumber given its

* real and imaginary parts.

* @param re The real component

* @param im The imaginary component

*/

public ComplexNumber(double re, double im) {

//Initialize the instance variables

}

/**

* Returns the real component.

* @return the real

*/

public double getReal() {

return 0.0; //A stub: to be fixed

}

/**

* Returns the imaginary component.

* @return the imaginary

*/

public double getImaginary() {

return 0.0; //A stub: to be fixed

}

/**

* Returns a new ComplexNumber number that is

* the negative of <em>this</em>. Note: the

* original ComplexNumber is <b>NOT</b>

* modified.

* @return -this

*/

public ComplexNumber negate() {

return null; //A stub: to be fixed

}

/**

* Returns a new ComplexNumber that is the

* sum of <em>this</em> and <em>z</em>.

* Note: the original ComplexNumber is

* <b>NOT</b> modified.

* @param z

* @return this + z

*/

public ComplexNumber add(ComplexNumber z) {

return null; //A stub: to be fixed

}

/**

* Returns a new ComplexNumber that is the

* difference of <em>this</em> and <em>z</em>.

* Note: the original ComplexNumber is

* <b>NOT</b> modified.

* @param z

* @return this + z

*/

public ComplexNumber subtract(ComplexNumber z) {

return null; //A stub: to be fixed

}

/**

* Returns a new ComplexNumber that is the

* product of <em>this</em> and <em>z</em>.

* Note: the original ComplexNumber is

* <b>NOT</b> modified.

* @param z

* @return this * z

*/

public ComplexNumber multiply(ComplexNumber z) {

return null; //A stub: to be fixed

}

/**

* Returns a new ComplexNumber that is

* the reciprocal of <em>this</em>.

* Note: the original ComplexNumber is

* <b>NOT</b> modified.

* @return 1.0 / this

*/

public ComplexNumber reciprocal() {

return null; //A stub: to be fixed

}

/**

* Returns a new ComplexNumber that is

* <em>this</em> divided by <em>z</em>.

* Note: the original ComplexNumber is

* <b>NOT</b> modified.

* @param z

* @return this / z

*/

public ComplexNumber divide(ComplexNumber z) {

return null; //A stub: to be fixed

}

/**

* Returns a String representation of

* <em>this</em> in the format:

* <pre>

* real +-(optional) i imaginary

* </pre>

* If the imaginary part is zero, only the

* real part is converted to a String.

* A "+" or "-" is placed between the real

* and imaginary parts depending on the

* the sign of the imagrinary part.

* <p>

* Examples:

* <pre>

* ..println(new ComplexNumber(0,0); -> "0.0"

* ..println(new ComplexNumber(1,1); -> "1.0 + i1.0"

* ..println(new ComplexNumber(1,-1); -> "1.0 - i1.0"

* </pre>

* @return the String representation.

*/

@Override

public String toString() {

//DO NOT MODIFY THIS CODE!

String str = "" + this.getReal();

if (this.getImaginary() == 0.0) {

return str;

}

if (this.getImaginary() > 0) {

return str + " + i" + this.getImaginary();

} else {

return str + " - i" + -this.getImaginary();

}

}

}

Reference no: EM13286806

Questions Cloud

What ways can vulnerable inmates be protected : What ways can vulnerable inmates be protected? Why are classification and housing assignments so critical to these populations?
Critics of american often that teacher''s unions represent : Which organization has proposed a set of standards for both elementary level and secondary-level teachers? According to the latest info.,  teachers will be most needed in which of the following areas: Critics of American often argue that teacher's un..
Morgellons disease is delusional : Why do some scientists say that Morgellons disease is delusional? When there have been fibers extracted from patients that cannot be identified? Isn't that physical proof that something is affecting these people physically?
Mutant bacterium-synthesize the amino acid tyrosine : Consider a mutant bacterium you have isolated which is unable to synthesize the amino acid tyrosine. You grow it in the presence of a chemical mutagen and isolate a single revertant, which is now able to grow in the absence of tyrosine
Java code that needs to be coded-complex number class : Just a Java Code that needs to be coded. Your given the design, just needs the methods and such to be fixed. This is for a Complex Number class.
What were the health challenges of the early culture : What were the health challenges of the Early culture ( the Eras of Egyptians, Greeks, Romans)? What were the factors/ beliefs, knowledge or lack of knowledge, etc. that influenced these health problems?
Enzymatic denaturation is a strong function of temperature : Increasing the temperature from 40 to 50 C increases kd by 32 fold. What is the value of Ed? Also, if the value of kd at 40C is 0.1 min-1, what is the percentage decrease in enzyme concentration during the enzymatic reaction carried out at 37C for 10..
Explain the ion movement that occur in each phase : List the phases of the cardiac muscle action potential and explain the ion movement that occur in each phase
Hiring a marketing firm : What considerations should an administrator take into account when hiring a marketing firm? How would you choose a company to help you market your practice?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd