Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Lab3{
- public static void main(String [] args){
- Scanner sc = new Scanner(System.in);
- int x,x2,x3;
- double result,result2,result3;
- System.out.println("Please enter the value of x");
- x = sc.nextInt();
- x2=x-1;
- x3=x+1;
- result = (x*x*x-4*(x+20))/2.0;
- result2= (x2*x2*x2-4*(x2+20))/2.0;
- result3= (x3*x3*x3-4*(x3+20))/2.0;
- System.out.println("F("+x+") = " + result);
- System.out.println("F("+x2+") = " + result2);
- System.out.println("F("+x3+") = " + result3);
- System.out.print("Thanks for using my program :)");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement