Write a program to collect the input float point numbers x a

Write a program to collect the input float point numbers x and y by using Scanner, and then display the result of 3x + 2y^2/4x - 5y middot 8 + 6x/7 xy by using System out. Write a program to calculate the area of a circle. Your program should take a float point number radius from an input dialog. Then calculate the circle area (pi r^2) and show it in a message dialog.

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

 Write a program to collect the input float point numbers x and y by using Scanner, and then display the result of 3x + 2y^2/4x - 5y middot 8 + 6x/7 xy by using
 Write a program to collect the input float point numbers x and y by using Scanner, and then display the result of 3x + 2y^2/4x - 5y middot 8 + 6x/7 xy by using

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site