Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //******************************************************************************
- // KAA - my simple Celsium to Fahrenheit Converter
- public class CelsiusToFahrenheitConverter {
- public static void main(String[] args) {
- double celsius1 = 0;
- double celsius2 = 20;
- double fahrenheit1 = celsius1 * 9 / 5 + 32;
- double fahrenheit2 = celsius2 * 9 / 5 + 32;
- System.out.println(celsius1 + " °C -> " + fahrenheit1 + " °F");
- System.out.println(celsius2 + " °C -> " + fahrenheit2 + " °F");
- }
- }
- //******************************************************************************
- // KAA - my simple Likes Statistic counter
- public class LikesStatistic {
- public static void main(String[] args) {
- long likesCount = 102;
- int registrationYear = 2013;
- int currentYear = java.time.Year.now().getValue();
- double likesPerYear = (double) likesCount / (currentYear - registrationYear + 1);
- System.out.println(likesPerYear + " likes / year");
- }
- }
- //******************************************************************************
- // KAA - my simple DigitsPrinter
- public class DigitsPrinter {
- public static void main(String[] args) {
- int n = 987654321;
- n = n % 100000;
- System.out.println( n / 10000 );
- n = n % 10000;
- System.out.println( n / 1000 );
- n = n % 1000;
- System.out.println( n / 100 );
- n = n % 100;
- System.out.println( n / 10 );
- System.out.println( n % 10 );
- }
- }
- //******************************************************************************
- // KAA - my simple Bytes Converter
- public class BytesConverter {
- public static void main(String[] args) {
- long totalBytes = 254318501496L;
- long gigaBytes = totalBytes / 1_073_741_824;
- long megaBytes = ((totalBytes - gigaBytes * 1_073_741_824)) / 1_048_576;
- long kiloBytes = ((totalBytes - gigaBytes * 1_073_741_824 - megaBytes * 1_048_576)) / 1024;
- long bytes = ((totalBytes - gigaBytes * 1_073_741_824 - megaBytes * 1_048_576 - kiloBytes * 1024));
- System.out.println(gigaBytes + " GB, " + megaBytes + " MB, " + kiloBytes + " KB, " + bytes + " B");
- }
- }
- //******************************************************************************
- // KAA - my simple Average Calculator
- public class AverageCalculator {
- public static void main(String[] args) {
- int a = 5;
- int b = 8;
- int avg = (a / 2 + b / 2) + (a % 2 + b % 2) / 2;
- System.out.println("avg = " + avg );
- }
- }
Add Comment
Please, Sign In to add comment