Computer Science, asked by rajeshbetuladop9qb9t, 1 year ago

WAP to obtain x, y, z from user and calculate the expression :

Attachments:

Answers

Answered by harindersaini2pcf8vf
1

For BlueJ (without Scanner class) :-

class hello

{

  void main(double x, double y, double z)

   {

     double ans;

     ans = 4*(x*x*x*x) + 3*(y*y*y) + 9*z + 6*(Math.PI);

     System.out.println("The answer is " + ans);

   }

 }



harindersaini2pcf8vf: please mark as brainliest if it really helped...please...please
harindersaini2pcf8vf: if you need with Scanner class then please tell I'll edit my answer.
Answered by BrainlyPromoter
3
Using Scanner class -
import java.util.Scanner;
class brainly
{
public void main(String args[])
{
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
int y = sc.nextInt();
int z = sc.nextInt();
int ans = 4*(x*x*x*x)+3*(y*y*y)+9*z+6*(22/7);
System.out.print(ans);
}
}


Without using Scanner class -
class brainly
{
public void main(int x,int y,int z)
{
int ans = 4*(x*x*x*x)+3*(y*y*y)+9*z+6*(22/7);
System.out.print(ans);
}
}

Using methods -
class brainly
{
public static int formula(int x,int y,int z)
{
int ans = 4*(x*x*x*x)+3*(y*y*y)+9*z+6*(22/7);
return ans;
}
public static void main(int x, int y, int z)
{
result = formula(x,y,z);
System.out.print(result);
}
Similar questions