fireurza Posted April 16, 2013 Member ID: 677 Group: ***- Inactive Clan Members Followers: 18 Topic Count: 172 Topics Per Day: 0.03 Content Count: 1457 Content Per Day: 0.26 Reputation: 791 Achievement Points: 9890 Solved Content: 0 Days Won: 5 Joined: 11/02/09 Status: Offline Last Seen: January 16, 2024 Birthday: 02/20/1986 Posted April 16, 2013 if anyone knows java please hit me up on xifre. i could really use some help with this homework assignment Awards
fireurza Posted April 16, 2013 Member ID: 677 Group: ***- Inactive Clan Members Followers: 18 Topic Count: 172 Topics Per Day: 0.03 Content Count: 1457 Content Per Day: 0.26 Reputation: 791 Achievement Points: 9890 Solved Content: 0 Days Won: 5 Joined: 11/02/09 Status: Offline Last Seen: January 16, 2024 Birthday: 02/20/1986 Author Posted April 16, 2013 here is the assignment... About the Application File The Complex objects should becreated in the application file and call the class methods. Theapplication program should contain a while loop that stops processing when allof the data from one file has been read. Ifthe file is empty, then a message should be displayed and all processingterminated. Nocalculations should be performed if the second set of values is zero for boththe real and imaginary parts. An errormessage should be displayed and processing should continue with the next set ofnumbers. The application program should contain one method that prints, but doesnot call the arithmetic methods, the labeled results of all arithmeticoperations (Specifics for output on next page.) The application program should have a heading that contains thefollowing information: your name, COSC1437, Programming Assignment #1, and thecurrent date About the Class File - use thisin your code Createa Complex number class that has twodouble fields, one that represents the real part and one that represents the imaginarypart of a complex number. All classmethods should use the this referencewhen referring to the calling object. Youshould also have the following class methods: Three classconstructors: a default constructor withthe real part assigned 1 and the imaginary part assigned 0 and anotherconstructor that has two parameters that initialize the real part and theimaginary part of the complex number and a copy constructor. One set operation with twoparameters that assigns values of the real part and the imaginary part of thecomplex number. Two get operations: one that returns the real part and one thatreturns the imaginary part. Four arithmetic operationsthat will add, subtract, multiply, and divide two complex numbers. These should be non-void (value-returning)methods that receive one Complexobject and return one Complex object. (Do not use a shallow copy. The getData method on page 356-357 (5thedition) and page 338-339 (4th edition) gives you an example of howto return class objects.). A toString method that writes onlythe value of the Complex object inthe form a + bi . An equals method that willcompare two Complex objects. Awards
fireurza Posted April 16, 2013 Member ID: 677 Group: ***- Inactive Clan Members Followers: 18 Topic Count: 172 Topics Per Day: 0.03 Content Count: 1457 Content Per Day: 0.26 Reputation: 791 Achievement Points: 9890 Solved Content: 0 Days Won: 5 Joined: 11/02/09 Status: Offline Last Seen: January 16, 2024 Birthday: 02/20/1986 Author Posted April 16, 2013 this is what i got... Application file.... import java.io.File;import java.io.FileWriter;import java.io.PrintWriter;import java.util.Scanner;import prog1.Complex;public class Imaginary{ public static void main(String[] args) { String infile; String outfile; String str; Scanner inputFile; PrintWriter outputFile; Complex first; Complex second; Scanner keyboard = new Scanner(System.in); System.out.println("Enter input file name :"); infile = keyboard.nextLine(); File myFile = new File(infile); inputFile = new Scanner(myFile); if(!inputFile.hasNext()) System.out.println("Nothing there!"); System.out.println("Enter output file name :"); outfile = keyboard.nextLine(); outputFile = new PrintWriter(new FileWriter(outfile)); while(inputFile.hasNext()) { if(second.getReal() == 0 || second.getImaginary() == 0) System.out.println("Can't use those number"); else } }} Awards
fireurza Posted April 16, 2013 Member ID: 677 Group: ***- Inactive Clan Members Followers: 18 Topic Count: 172 Topics Per Day: 0.03 Content Count: 1457 Content Per Day: 0.26 Reputation: 791 Achievement Points: 9890 Solved Content: 0 Days Won: 5 Joined: 11/02/09 Status: Offline Last Seen: January 16, 2024 Birthday: 02/20/1986 Author Posted April 16, 2013 class file.... package prog1;public class Complex{ public double a; public double b; public Complex() { this.a = 1; this.b = 0; } public Complex(double a, double { this.a = a; this.b = b; } public Complex(Complex equation) { this.a = equation.a; this.b = equation.b; } public void setComplexNumber(double a, double { this.a = a; this.b = b; } public double getReal() { return this.a; } public double getImaginary() { return this.b; } public Complex add(Complex cn) { return new Complex(this.a + cn.a, this.b + cn.; } public Complex subtract(Complex cn) { return new Complex(this.a - cn.a, this.b - cn.; } public Complex multiply(Complex cn) { return new Complex(this.a * cn.a, this.b * cn.; } public Complex divide(Complex cn) { return new Complex(this.a / cn.a,this.b / cn.b ); } public String toString() { String str; str = "" + getReal() + " + " + getImaginary() + "i"; return str; } public Boolean equals(Complex equation) { if (this.a == equation.a && this.b == equation. return true; else return false; } } Awards
KaptCrunch Posted April 16, 2013 Member ID: 389 Group: *** Clan Members Followers: 48 Topic Count: 316 Topics Per Day: 0.06 Content Count: 4878 Content Per Day: 0.85 Reputation: 4062 Achievement Points: 39472 Solved Content: 0 Days Won: 51 Joined: 09/14/09 Status: Offline Last Seen: 21 minutes ago Birthday: 01/01/1970 Device: Windows Posted April 16, 2013 read explore the coffee bug oracle Awards
Recommended Posts