| New file |
| | |
| | | public class CMYKtoRGB { |
| | | public static void main(String[] args) { |
| | | double c = Double.parseDouble(args[0]); |
| | | double m = Double.parseDouble(args[1]); |
| | | double y = Double.parseDouble(args[2]); |
| | | double k = Double.parseDouble(args[3]); |
| | | |
| | | double w = 1 - k; |
| | | int r = (int) Math.round(255 * w * (1 - c)); |
| | | int g = (int) Math.round(255 * w * (1 - m)); |
| | | int b = (int) Math.round(255 * w * (1 - y)); |
| | | |
| | | System.out.println("red = " + r); |
| | | System.out.println("green = " + g); |
| | | System.out.println("blue = " + b); |
| | | } |
| | | } |
| New file |
| | |
| | | public class CasualNumber { |
| | | public static void main(String[] args) { |
| | | double uno, due, tre, quattro, cinque; |
| | | double medio, massimo, minimo; |
| | | uno = Math.random(); |
| | | due = Math.random(); |
| | | tre = Math.random(); |
| | | quattro = Math.random(); |
| | | cinque = Math.random(); |
| | | medio = (uno + due + tre + quattro + cinque) / 5; |
| | | minimo = Math.min(uno, due); |
| | | minimo = Math.min(minimo, due); |
| | | minimo = Math.min(minimo, tre); |
| | | minimo = Math.min(minimo, quattro); |
| | | minimo = Math.min(minimo, cinque); |
| | | massimo = Math.max(uno, due); |
| | | massimo = Math.max(massimo, tre); |
| | | massimo = Math.max(massimo, quattro); |
| | | massimo = Math.max(massimo, cinque); |
| | | System.out.println("uno " + uno); |
| | | System.out.println("due " + due); |
| | | System.out.println("tre " + tre); |
| | | System.out.println("quattro " + quattro); |
| | | System.out.println("cinque " + cinque); |
| | | System.out.println("medio " + medio); |
| | | System.out.println("minimo " + minimo); |
| | | System.out.println("massimo " + massimo); |
| | | } |
| | | } |
| New file |
| | |
| | | public class GreatCircle { |
| | | public static void main(String[] args) { |
| | | double x1 = Double.parseDouble(args[0]); |
| | | double y1 = Double.parseDouble(args[1]); |
| | | double x2 = Double.parseDouble(args[2]); |
| | | double y2 = Double.parseDouble(args[3]); |
| | | |
| | | double r = 6371.0; // Earth radius |
| | | |
| | | double dx = Math.toRadians(x2 - x1) / 2.0; |
| | | double dy = Math.toRadians(y2 - y1) / 2.0; |
| | | |
| | | double under = Math.sin(dx) * Math.sin(dx) + |
| | | Math.cos(Math.toRadians(x1)) * Math.cos(Math.toRadians(x2)) |
| | | * Math.sin(dy) * Math.sin(dy); |
| | | |
| | | double distance = 2.0 * r * Math.asin(Math.sqrt(under)); |
| | | |
| | | System.out.println(distance + " kilometers"); |
| | | } |
| | | } |
| New file |
| | |
| | | public class HelloGoodbye { |
| | | public static void main(String[] args) { |
| | | System.out.println("Hello " + args[0] + " and " + args[1]); |
| | | System.out.println("Goodbye " + args[1] + " and " + args[0]); |
| | | } |
| | | } |
| New file |
| | |
| | | class HelloWorld { |
| | | public static void main(String[] args) { |
| | | System.out.println("Hello World"); |
| | | } |
| | | } |
| New file |
| | |
| | | public class RightTriangle { |
| | | public static void main(String[] args) { |
| | | int a = Integer.parseInt(args[0]); |
| | | int b = Integer.parseInt(args[1]); |
| | | int c = Integer.parseInt(args[2]); |
| | | int a1, a2, last, first, middle; |
| | | |
| | | a1 = Math.min(a, b); |
| | | a2 = Math.max(a, b); |
| | | last = Math.max(a2, c); |
| | | a2 = Math.min(a2, c); |
| | | first = Math.min(a1, a2); |
| | | middle = Math.max(a1, a2); |
| | | |
| | | boolean r1 = first > 0; |
| | | boolean r2 = middle > 0; |
| | | boolean r3 = last > 0; |
| | | |
| | | boolean result = (first * first + middle * middle) == (last * last); |
| | | System.out.println(r1 && r2 && r3 && result); |
| | | } |
| | | } |
| New file |
| | |
| | | public class SortTreeInteger { |
| | | public static void main(String[] args) { |
| | | int a = Integer.parseInt(args[0]); |
| | | int b = Integer.parseInt(args[1]); |
| | | int c = Integer.parseInt(args[2]); |
| | | int a1, a2, last, first, middle; |
| | | |
| | | a1 = Math.min(a,b); |
| | | a2 = Math.max(a,b); |
| | | last = Math.max(a2,c); |
| | | a2 = Math.min(a2,c); |
| | | first = Math.min(a1,a2); |
| | | middle = Math.max(a1,a2); |
| | | |
| | | System.out.println("i tre numeri ordinati: " + first + " " + middle + " " + last); |
| | | } |
| | | } |