Sheet 3
Sheet 3
Sample output 2:
Enter the first number: 55
Enter the second number: 10
55 + 10 = 65
55 - 10 = 45
55 * 10 = 550
55 / 10 = 5
55 % 10 = 5
The program will read from the user, the coefficients a, b, and c, print
the equation in the form ax 2 +bx+c=0 with the values of the coefficients
and finally print the roots of the equation. You may assume that the
equation has two real roots, though mathematically this is not always the
case.
1|Page
Sample output 1:
Enter coefficient a: 2
Enter coefficient b: 3
Enter coefficient c: 1
The form of the equation: 2x^2+3x +1=0
The first root of the equation = -0.5
The second root of the equation = -1.0
Sample output 2:
Enter coefficient a: 2
Enter coefficient b: 5
Enter coefficient c: 2
The form of the equation: 2x^2+5x +2=0
The first root of the equation = -0.5
The second root of the equation = -2.0
The program will finally print the coordinates of the points and the
distance between those two points.
Sample output 1:
Enter the values of Coordinates of point A:
x1=2
y1=1
Enter the values of Coordinates of point B:
x2=3
y2=4
The Distance between the two points A(2,1)and B(3,4) equals
3.1622776601683795
Sample output 2:
Enter the values of Coordinates of point A:
x1=1
y1=2
Enter the values of Coordinates of point B:
x2=4
2|Page
y2=6
The Distance between the two points A(1,2)and B(4,6) equals 5.0
4. Write a java program that will ask the user to enter a number, the program
will use the Math library to calculate and print the absolute value, the rounded
value, the ceiling value, the floor value and the number raised to the power of two
value.
Sample output 1:
Enter a decimal number:-2.3512
The absolute value of -2.3512 = 2.3512
The rounded value of -2.3512 = -2
The ceiling of -2.3512 = -2.0
The floor of -2.3512 = -3.0
(-2.3512)^2 = 5.52814144
Sample output 2:
Enter a decimal number: 4.3268
The absolute value of 4.3268 = 4.3268
The rounded value of 4.3268 = 4
The ceiling of 4.3268 = 5.0
The floor of 4.3268 = 4.0
(4.3268)^2 = 18.721198240000003
3|Page