The \b special character

Ok, I usually use JCreator for programming because it's simple... very simple, but I'm using Eclipse right now because that's all this PC has. For some reason, it won't make the \b character backspace. Here's the code, what should Ido?:

import javax.swing.JOptionPane;

import java.text.DecimalFormat;

publicclass Quadratic

{

publicstaticvoid main(String[] args)

{

System.out.println("This program will solve the quadratic formula for you.");

int cont = 0;

String back ="";

do

{

double a = Double.parseDouble(JOptionPane.showInputDialog("What is the value of a?"));

double b = Double.parseDouble(JOptionPane.showInputDialog("What is the value of b?"));

double c = Double.parseDouble(JOptionPane.showInputDialog("What is the value of c?"));

double det = (Math.pow(b,2))-(4 * a * c);

if (det < 0)

{

back ="The determinant is " + Math.sqrt(-det) +"i.";

System.out.print(back);

Quadratic.imaginary(a,b,det);

}

elseif (det >= 0)

{

back ="The determinant is " + det;

System.out.print(back);

Quadratic.real(a,b,det);

}

cont = JOptionPane.showConfirmDialog(null,"Would you like to solve another equation?");

for (int i = 0;i < back.length();i++)

System.out.print("\b");

for (int j = 0;j < back.length();j++)

System.out.print(" ");

for (int k = 0;k < back.length();k++)

System.out.print("\b");

}while(cont == 0);

}

publicstaticvoid imaginary(double a,double b,double det)

{

DecimalFormat formatter =new DecimalFormat("0.000");

det = Math.sqrt(-det);

double gmc = Quadratic.GCM(a,b,det);

a/=gmc;

b/=gmc;

det/=gmc;

if (det == 1)

JOptionPane.showMessageDialog(null,"X= " + a +" +- " + formatter.format(det) +"i");

else

JOptionPane.showMessageDialog(null,"X= ("+ a +" +- " + formatter.format(det) +"i)/" + (a * 2));

}

publicstaticvoid real(double a,double b,double det)

{

DecimalFormat formatter =new DecimalFormat("0.000");

det = Math.sqrt(det);

JOptionPane.showMessageDialog(null,"X= " + formatter.format((-b + det) / (a * 2)) +" , " + formatter.format((-b - det) / (a * 2)));

}

publicstaticdouble GCM(double a,double b,double det)

{

int x = 1;

double gcm = 1;

double small = 0;

if ((a <= b) && (a <= det))

small = a;

if ((b <= a) && (b <= det))

small = b;

if ((det <= a) && (det <= b))

small = det;

do

{

if ((a % x == 0) && (b % x == 0) && (det % x == 0))

gcm = x;

x++;

}while(x <= small);

return gcm;

}

}

[5719 byte] By [TheGuy@YourWindowa] at [2007-10-2 6:04:06]
# 1
This isn't much help to you, but I just compiled and ran that in JCreator. Backspacing worked fine.
ConanOfOza at 2007-7-16 13:04:31 > top of Java-index,Java Essentials,New To Java...
# 2
Ya, I know. That's what's totally making me mad. It'll work just fine in JCreator, but in Eclipse it just makes a bunch of box things. I don't get why.
TheGuy@YourWindowa at 2007-7-16 13:04:31 > top of Java-index,Java Essentials,New To Java...
# 3
What is a backspace supposed to do in System.out anyway?
DrClapa at 2007-7-16 13:04:31 > top of Java-index,Java Essentials,New To Java...
# 4
It makes the cursor go backwards. I use it to go backwards, then I write a bunch of spaces over what was there, and then I make it go backwards again. Then if they choose to solve another equation, it will write the results on the same line.
TheGuy@YourWindowa at 2007-7-16 13:04:31 > top of Java-index,Java Essentials,New To Java...
# 5

> It makes the cursor go backwards. I use it to go

> backwards, then I write a bunch of spaces over what

> was there, and then I make it go backwards again.

> Then if they choose to solve another equation, it

> will write the results on the same line.

That will only work on a limited set of platforms, your application might not always work as expected.

Kaj

kajbja at 2007-7-16 13:04:31 > top of Java-index,Java Essentials,New To Java...
# 6
Besides, if you're using the console for anything more than just basic input and output you ought to be writing a GUI application anyway.
DrClapa at 2007-7-16 13:04:31 > top of Java-index,Java Essentials,New To Java...