how to write a program in Java with imaginary numbers, I have no idea where to start.?
471250
Fairly straight forward. The code below is the skeletal C++ code (since I am not familiar with Java).\n\nclass Complex {\npublic:\nComplex () {a = 0; b = 0;}\nComplex (float x, float y) { a = x; b = y;}\nfloat real () {return a;}\nfloat imaginary () {return b;}\nvoid Add (Complex c, Complex d) { a = c.real() + d.real();\nb = c.imaginary() + d.imaginary();}\nvoid Subtract (Complex c, Complex d) {....}\nvoid Print() { cout << a << "+ i" << b; }\nprivate:\nfloat a;\nfloat b;\n};
49715
use bitwise operators. something like:\n\nnum_bits = 0;\nfor(i = 0; i < 32; i++) {\nif number & (1<<i) num_bits++;\n}\n\nnow num_bits holds the number of bits that were set in number. The "<<" operator does bit shifting. So "1<<i" equals a number that's all 0's except for a 1 at position i. If you bitwise and that with something, that tells you if that bit is set in the number. So we do this for each of the bits and add up the results.\n\nThis is assuming 32-bit integers. Adjust accordingly for 64-bit integers.
938758
write a program which will read the number as units,10's,100';s,1000's,10000's,100000's,1000000's,100000000's etc and store appropriate in english.  refer it and print eg.\n\n123 to print as one hundered and twenty three\n\n3  ---> store as three in a unit table  (3 is in unit, so read as three)\n2 ----> store as twenty in a ten table (2 is in 10, so read as twenty)\n1 ---->  store as one hundred in hundred table  (1 is in 100, so read as hundred)\n\nthen concantenate from the left\ni.e. one hundered twenty three \n\nadd only in the end\n\nwrite a program.  use brain to write the program.  there are so many ways, so many logic.  never post this type of question.\n\neach person's logic vary.  may be there will be very easy way of doing it.   and this program is very old.  this may have been written by innumerable number of programmers.  \n\nbye
101861
The Integer class includes a method named parseInt() that serves just this purpose. An example of a simple program that performs this conversion is shown below:\n\n\npublic class s2i {\n\n   public static void main (String[] args) {\n\n      // String s = "fred";    // do this if you want an exception\n\n      String s = "100";\n\n      try {\n         int i = Integer.parseInt(s.trim());\n         System.out.println("int i = " + i);\n      } catch (NumberFormatException nfe) {\n         System.out.println("NumberFormatException: " + nfe.getMessage());\n      }\n\n   }\n\n}\n\n\n\nOther notes\n\nInteger.toString(int i) is used to convert in the other direction, from int to String. \n  \nIf you're interested in converting a String to an Integer object, use the valueOf() method of the Integer class instead of the parseInt() method.
681247
Ordinary numbers can be represented as a line, like a ruler.   There's 0, 1 is to the right of it, 2 is further right, 1.5 is halfway between 1 and 2 and so on.   Complex numbers can be represented as points on a flat surface.   There's a real part like an ordinary number, and an imaginary part, which is a multiple of the square root of minus 1, written as i.   So 3-2i is the point you get to when you start off at the origin (like the origin of an x,y graph)You go 3 to the right and 2 down.   3+2i would be 3 to the right and 2 up.   Let's call a complex number z.   Turn z into (z times z) +1.   Call this z.   Do the same thing again, again and again, say 1000 times. z will either get bigger and bigger without limit or it will stay small.   The set of values of z that stay small is the Mandelbrot Set.   You can draw a picture of it.   If your piece of paper is white, and you make a black mark for every point on it corresponding to a complex number in the Mandelbrot Set, you get a black shape looking a bit like a peach with warts on it.   It's infinitely complicated; if you magnify the edge, you see more and more detail.
40697
imaginary numbers are used in physics and engineering to describe waves.  it does not mean that the physical thing you are describing is imaginary, but rather that the mathematics that describes it uses complex numbers.\n\ncomplex numbers are made up of 2 parts:  one part is called "real" and the other part is called "imaginary".  the imaginary part is just a real number multiplied by i, where i is defined as the square root of -1.  so a complex number looks like: 4 + 7i.\n\nif you know any basic math, you know that square root is only defined on the positive real numbers.  think about it - you cannot square anything and get a negative number, because the minus signs always cancel.  this is why the square root of -1 is called "imaginary" - the concept was derided for a long time by early mathematicians, until it was seen to be so useful that people finally accepted it.\n\nthe relationship with a wave comes from euler's equation:\n\ne^ix = cos x + i*sin x\n\nas you can see, e raised to an "imaginary" power can be written as the sum of 2 waves.  there are a lot of applications in physics and engineering where it is far more convenient to write the equation for a wave in terms of an exponential rather than in terms of sine and cosine.  in fact, in many advanced works you almost never see sin/cos and waves are often only described as a complex exponential.
770189
Number will have to be the actual number it is working it out from..and it might not work as a long and definately not an integer.\n\nNumber as String\nOdd as Long (or Integer)\nEven as Long ( or Integer)\n\nIf Not (Number <1 or Number > 10) Then\nNumber = Number / 2\nIf InStr(Number, ".5") then\nOdd = Odd + 1\nElse\nEven = Even + 1\nEnd If\nEnd If\nMe.Print "Odd: " & Odd & " - " & "Even: " & Even
755691
U have to use JavaScript for calculations.\nThere is a function 'eval' in JavaScript that takes the operators and operands as input and returns the result.\n\nE.g:  eval(7*5), it will return 35.
284143
j * sqrt(pi)\n\nj = i; which is imaginary number which is sqrt(-1)\nsqrt is "square root"
253284
#include <stdio.h>\n\nint main(void) {\n\nint i, j, count; //C Sucks, wait till you take java\n\nfor(i=1; i<=1000; i++){&#92;&#92;goes through all numbers 1 to 1000\n    count=0;\n    for(j=2; j<i; j++)&#92;&#92;goes through all numbers 2 to i\n    {\n     if(i%j==0)&#92;&#92;checks to see if it i is evenly div. by i\n        count++;\n    }//nested for\n    if (count ==0)\n        printf("%d&#92;n", i);\n}//for\n\nreturn 0;\n}//main\n\n\n//Hope that helps!
901674
Here is a Baldwin tutorial on FFT (he writes how-to Java articals for Developer.com):\nhttp://www.developer.com/java/other/article.php/3457251
241489
Try any of this code\nDim i as integer=Convert.ToInt32("your number as string")\nor\nDim i as integer=Val("your number as string")\nor\nDim i as integer=CInt("your number as string")
654434
Yes, there is. The square root of negative 1 is the number i, which is an "Imaginary Number." \n\nDespite the name, imaginary numbers are real quantities that are used in equations to get real answers. However, they are a somewhat confusing concept, mathematically. \n\nOne way to visualize them is to consider that multiplication by an imaginary number rotates a function orthogonally on a number axis. The answers given by performing this procedure once may not seem to be applicable to real situatons, but if you multiply by an imaginary number again, in rotates the function back onto the initial axis, yielding real number results. \n\nI am including links to a number of good sites on imaginary numbers. Although it can be difficult to understand the implications of imaginary numbers beyond the fact that their squares are negative, if you spend some time on these sites, I'm sure you'll come to understand them.
1153308
import java.io.IOException;\n\npublic class PosNeg {\n\npublic static void main(String[] args) {\n\nint [] wNumbers;\nwNumbers = new int[5];\nchar c = ' ';\n\nfor (int i=0;i<5;i++) {\nSystem.out.print("Enter the #"+i+": ");\ntry {\nwNumbers[i]=System.in.read()-48;\nif (wNumbers[i]<0)\nwNumbers[i]=(System.in.read()-48)*-1;\nwhile (System.in.read()!='&#92;n'){\n}\n} catch (IOException e) {\ne.printStackTrace();\n}\nSystem.out.print("The number you entered is ");\nif (Math.abs(wNumbers[i])!=wNumbers[i])\n   System.out.println("negative.");\n else\n   System.out.println("positive.");\n}\n}\n}
408935
Hey,\nthe code in JAVA would look like this ::\n\nclass test {\npublic static void main(String a[]) {\nfor(int i=1;i<100;i++) {\nSystem.out.print("&#92;t"+i+"&#92;n");\n}\n}\n}
451055
hehe .. the above answer is funny!!\n\nthe above program simply squares a number and returns.\n\nLet the eqn be of form ax^2 + bx + c =0\n\nprocess is dumb actually.. first find delta (delta = b^2 - (4 *a*c))\n\nroots of equation are : [-(b) + sqrt(delta) ]/(4*a*c) AND [-(b) - sqrt(delta) ]/(2*a)\n\n\nok.. here's a program to solve a quadratic equation :\n\nits in java ..\n\n\nimport java.io.*;\nclass quadra\n{\npublic static void main(String args[])throws\n\nIOException\n{\nint a,b,c;\n\ndouble delta,root1,root2;\nSystem.out.println(" Enter coefficient of x^2 ");\n\nBufferedReader br = new BufferedReader(new\n\nInputStreamReader(System.in));\n\na = Integer.parseInt(br.readLine() );\n\nSystem.out.println(" Enter coefficient of x ");\n\n\nb = Integer.parseInt(br.readLine() );\n\nSystem.out.println(" Enter coefficient of\n\nconstant");\n\nc = Integer.parseInt(br.readLine() );\n\ndelta = (b*b) - (4*a*c);\n\nroot1 = ((-(b)) + Math.sqrt(delta)) / (2*a);\nroot2 = ((-(b)) - Math.sqrt(delta)) / (2*a);\n\nSystem.out.println("roots are"+ root1 +"and"+\n\nroot2);\n\n}\n}\n\n\nhope i have answered ur question\n; )\n\nif u want program in C\nmail me: anand_87123@yahoo.com\nsubject line : Y! answers - programming
1146301
There is a book called "the Trachtenberg System" which explains a lot of computational shortcuts you can do in your head. It's probably in your local library.\nHere's an example of how to square a 2-digit number\n Rules: \n1. Square the second digit \n2. Multiply the two digits and double \n3. Square the first digit \nExample:\n34^2 (^2 is used for the "squared" symbol)\n   6          4^2  is 16; write 6, carry 1 \n  5          3x4x2 is 24, +1(carry) is 25; write 5, carry 2 \n11            3^2  is 9, +2(carry) is 11\n1156 \n34^2  = 1156