Guest User

Untitled

a guest
Dec 14th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. //******************************************************************************
  2. // KAA - my simple Celsium to Fahrenheit Converter
  3.  
  4. public class CelsiusToFahrenheitConverter {
  5.  
  6. public static void main(String[] args) {
  7. double celsius1 = 0;
  8. double celsius2 = 20;
  9.  
  10. double fahrenheit1 = celsius1 * 9 / 5 + 32;
  11. double fahrenheit2 = celsius2 * 9 / 5 + 32;
  12. System.out.println(celsius1 + " °C -> " + fahrenheit1 + " °F");
  13. System.out.println(celsius2 + " °C -> " + fahrenheit2 + " °F");
  14. }
  15. }
  16.  
  17. //******************************************************************************
  18. // KAA - my simple Likes Statistic counter
  19.  
  20. public class LikesStatistic {
  21.  
  22. public static void main(String[] args) {
  23. long likesCount = 102;
  24. int registrationYear = 2013;
  25. int currentYear = java.time.Year.now().getValue();
  26.  
  27. double likesPerYear = (double) likesCount / (currentYear - registrationYear + 1);
  28.  
  29. System.out.println(likesPerYear + " likes / year");
  30. }
  31. }
  32.  
  33. //******************************************************************************
  34. // KAA - my simple DigitsPrinter
  35. public class DigitsPrinter {
  36. public static void main(String[] args) {
  37. int n = 987654321;
  38.  
  39. n = n % 100000;
  40. System.out.println( n / 10000 );
  41. n = n % 10000;
  42. System.out.println( n / 1000 );
  43. n = n % 1000;
  44. System.out.println( n / 100 );
  45. n = n % 100;
  46. System.out.println( n / 10 );
  47. System.out.println( n % 10 );
  48.  
  49. }
  50.  
  51. }
  52. //******************************************************************************
  53. // KAA - my simple Bytes Converter
  54. public class BytesConverter {
  55. public static void main(String[] args) {
  56. long totalBytes = 254318501496L;
  57.  
  58. long gigaBytes = totalBytes / 1_073_741_824;
  59. long megaBytes = ((totalBytes - gigaBytes * 1_073_741_824)) / 1_048_576;
  60. long kiloBytes = ((totalBytes - gigaBytes * 1_073_741_824 - megaBytes * 1_048_576)) / 1024;
  61. long bytes = ((totalBytes - gigaBytes * 1_073_741_824 - megaBytes * 1_048_576 - kiloBytes * 1024));
  62.  
  63. System.out.println(gigaBytes + " GB, " + megaBytes + " MB, " + kiloBytes + " KB, " + bytes + " B");
  64.  
  65. }
  66. }
  67. //******************************************************************************
  68. // KAA - my simple Average Calculator
  69. public class AverageCalculator {
  70.  
  71. public static void main(String[] args) {
  72. int a = 5;
  73. int b = 8;
  74.  
  75. int avg = (a / 2 + b / 2) + (a % 2 + b % 2) / 2;
  76.  
  77. System.out.println("avg = " + avg );
  78.  
  79. }
  80. }
Add Comment
Please, Sign In to add comment