import java.util.*;
class Degree2
{
    Scanner in()
    {   return new Scanner(System.in);  }

    void out(String m)
    {   System.out.print(m);    }

    double readDouble(String m)
    {
        out(m);
        return in().nextDouble();
    }

    String readString(String m)
    {
        out(m);
        return in().nextLine();
    }

    void foundRoot(double a,double b,double c)
    {
        if(a==0)
            out("Value x is: "+(-c/b)+"\n");
        else
        {
            double data=(b*b)-(4*a*c);
            if(data>=0)
            {
                out("Value x1 is: "+((-b-Math.sqrt(data))/(2*a))+"\n");
                out("Value x2 is: "+((-b+Math.sqrt(data))/(2*a))+"\n");
            }
            else
                out("The Degree is no root.\n");
        }
    }

    public Degree2()
    {
        double a,b,c;
        String ch;
        do
        {
            a=readDouble("Enter Value A: ");
            b=readDouble("Enter Value B: ");
            c=readDouble("Enter Value C: ");
            foundRoot(a,b,c);
            ch=readString("Test again (Yes/No): ");
        }while("Yes".equalsIgnoreCase(ch)|"Y".equalsIgnoreCase(ch));
    }

    public static void main(String[] args)
    {   new Degree2();  }
}

I want to clear screen in my program. Please, do help me!!!

Member Avatar for harsh2327

There is no way to clear the screen in JAVA. It seems that you are a beginner in Java and just migrated from age old Turbo C.

The reason because there is no clear screen is that you will never need it when you develop actual Java programs. Have you ever seen an application that clears it screen (apart from DOS based applications).

When you develop an application for a client, you do not expect him/her to go through your clumsy console. The console is available only for debugging purposes or for learning the language. When you deploy your application, you always have an interface associated with it (like your own internet browser or any other window).

So stop worrying about clearing the screen.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.