Write a program to collect the input float point numbers x a
Solution
1)
EquationSubstitution.java
import java.util.Scanner;
public class EquationSubstitution {
public static void main(String[] args) {
//Declaring variables
float x,y,result;
// Scanner Class Object is used to get the inputs entered by the user
Scanner sc = new Scanner(System.in);
//Getting the number x entered by the user
System.out.print(\"Enter Number x (float type) :\");
x=sc.nextFloat();
//Getting the number y entered by the user
System.out.print(\"Enter Number y (float type) :\");
y=sc.nextFloat();
//calculating the result
result=((3*x)+(2*y*y)/(4*x)-(5*y))*(8+(6*x))/(7*x*y);
//Displaying the result.
System.out.printf(\"The result is :%.3f \",result);
}
}
______________________________________________
Output:
Enter Number x (float type) :7.0
Enter Number y (float type) :2.5
The result is :3.652
______________________________________________
2)
package org.students;
import java.util.Scanner;
public class AreaOfCircle {
public static void main(String[] args) {
//Declaring variables
float radius,area_of_circle;
// Scanner Class Object is used to get the inputs entered by the user
Scanner sc = new Scanner(System.in);
//Getting the radius entered by the user
System.out.print(\"Enter Radius :\");
radius=sc.nextFloat();
//Calculating the area of the circle
area_of_circle=(float) (Math.PI*radius*radius);
//Displaying the area of the circle
System.out.printf(\"The Area of the Circle is %.2f\",area_of_circle);
}
}
__________________________________________
output:
Enter Radius :5.5
The Area of the Circle is 95.03
________________________Thank You

