Guest User

Solve for Z

a guest
Sep 26th, 2015
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Example
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int x, y, z; // Assign "int" type too three variables "x, y, z".
  13.  
  14. x = 100; // Assign value 100 to x.
  15. y = 210; // Assign value 210 to y.
  16. z = 0; // Assign value 0 to z.
  17.  
  18. System.out.println("Solve for z when z = 0, x = 100, y = 210");
  19.  
  20. x = y / 2; // Assign: Divide y where y is 210 by 2 where x is now 105.
  21. z = x + y; // Assign: Add x where x is 205 to y 105 where z is 305.
  22.  
  23. System.out.print("The value of z where y/2 + x is " + z);
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment