Advertisement
Guest User

Untitled

a guest
Oct 20th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. import java.util.Scanner;
  2. class Lab3{
  3.     public static void main(String [] args){
  4.  
  5.             Scanner sc = new Scanner(System.in);
  6.  
  7.             int x;
  8.  
  9.             System.out.println("Please enter the value of x");
  10.  
  11.             x = sc.nextInt();
  12.  
  13.             double result;
  14.             result = (x*x*x-4*(x+20))/2.0;
  15.             System.out.println("F("+x+") = " + result);
  16.  
  17.             x = x - 1;
  18.             result = (x*x*x-4*(x+20))/2.0;
  19.             System.out.println("F("+x+") = " + result);
  20.  
  21.             x = x + 2 ;
  22.             result = (x*x*x-4*(x+20))/2.0;
  23.             System.out.println("F("+x+") = " + result);
  24.  
  25.             System.out.print("Thanks for using my program :)");
  26.         }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement