WAP to obtain x, y, z from user and calculate the expression :
Attachments:
Answers
Answered by
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
Answered by
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);
}
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
Psychology,
6 months ago
Computer Science,
6 months ago
Physics,
1 year ago
Math,
1 year ago
Math,
1 year ago
Math,
1 year ago