HW5.1】的更多相关文章

import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the number of sides: "); int n = input.nextInt(); System.out.print("Enter the length…
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the length of side: "); double side = input.nextDouble(); input.close(); System.out.printl…
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the year: "); int year = input.nextInt(); input.close(); for(int i = 1; i <= 12; i++) S…
import java.util.Calendar; public class Solution { public static void main(String[] args) { long totalMillis = System.currentTimeMillis(); long totalSeconds = totalMillis / 1000; long second = totalSeconds % 60; long totalMinutes = totalSeconds / 60;…
public class Solution { public static void main(String[] args) { int n1 = (int)(Math.random() * 5 + 1); int n2 = (int)(Math.random() * 5 + 1); int winCount = 0; for(int i = 0; i < 10000; i++) { if(diceGame(n1, n2)) winCount++; n1 = (int)(Math.random(…
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter an ID number: "); long id = input.nextLong(); input.close(); System.out.println(isValid(id…
public class Solution { public static void main(String[] args) { for(int i = 3; i <= 1000; i++) if(isDoublePrime(i)) System.out.println("(" + i + ", " + (i + 2) + ")"); } public static boolean isDoublePrime(int n) { if(isP…
public class Solution { public static void main(String[] args) { int n1 = (int)(Math.random() * 5 + 1); int n2 = (int)(Math.random() * 5 + 1); diceGame(n1, n2); } public static void diceGame(int n1, int n2) { if(n1 + n2 == 2 || n1 + n2 == 3 || n1 + n…
public class Solution { public static void main(String[] args) { System.out.printf("%s\t%s\n", "p", "2^p - 1"); for(int i = 2; i <= 31; i++) { if(isPrime((int)getMersenne(i))) System.out.printf("%d\t%d\n", i, (in…
public class Solution { public static void main(String[] args) { int totalCount = 0; int lineCount = 0; int i = 2; while(true) { if(isPrime(i) && (isPrime(getReverse(i)))) { System.out.printf("%d\t", i); totalCount++; lineCount++; } i++;…