Guest User

Untitled

a guest
Feb 16th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. public class ByteShortInt {
  2.  
  3. public static void main(String[]args) {
  4.  
  5. //Integer has width of 32
  6. int myMinValue = -2_147_483_648;
  7. int myMaxValue= 2_147_483_647;
  8. int myTotal=(myMinValue/2);
  9. System.out.println("mytotal ="+myTotal);
  10. //byte has a width of 8
  11. byte myByteValue = -128;
  12. byte myNewByteValue=(byte)(myByteValue/2);
  13. System.out.println("myNewByteValue"+ myNewByteValue);
  14.  
  15. //short has a width of 16
  16. short myshortValue = 32767;
  17.  
  18. //long has width of 64
  19. long mylongValue=9_223_372_036_854_775_807L;
  20.  
  21. //ASSINGMENT
  22. //1. create a byte variable and set it to any valid byte number
  23. byte myBytevalue2 =10;
  24.  
  25. //2.create a short variable and set it to any valid short number
  26. short myShortvalue2=20;
  27. //3. create a int variable and set it to any valid int number
  28. int myIntvariable2=50;
  29. //4.create a variable of type long,and make it to equal to 5000+10 times the sum of the byte ,plus the short plus the int
  30. long myLongValue=50000 + 10 *(myBytevalue2+myShortvalue2+myIntvariable2);
  31. System.out.println("my value is " + myLongValue);
  32.  
  33. }
  34. }
Add Comment
Please, Sign In to add comment