Lab Programs
Lab Programs
System.out.println("Original Values:");
System.out.println("Byte: " + b);
System.out.println("Short: " + s);
System.out.println("Int: " + i);
System.out.println("Long: " + l);
System.out.println("Float: " + f);
System.out.println("Double: " + d);
System.out.println("Char: " + c);
System.out.println(" ");
double p=i;
int q= (int)d;
double r = f;
int g= b + s;
}
}
import java.io.DataInputStream;
import java.io.IOException;
}
}
class qe
{
public static void main(String[] args) throws IOException
{
DataInputStream dis = new DataInputStream(System.in);
double discriminant = b * b - 4 * a * c;
if (discriminant >0)
{
double root1 = (-b + Math.sqrt(discriminant)) / (2 * a);
double root2 = (-b - Math.sqrt(discriminant)) / (2 * a);
System.out.println("Roots are real and distinct: " + root1 + ", " + root2);
}
else
{
if(discriminant==0)
{
double root = -b / (2 * a);
System.out.println("Roots are real and equal: " + root);
}
else
{
System.out.println("Roots are complex and distinct.");
}
}
}
}