HW4.3】的更多相关文章

import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter an integer: "); int number = input.nextInt(); int mask = 1; for(int i = 15; i > 0; i--)…
public class Solution { public static void main(String[] args) { int count = 0; for(int i = 1; i <= 7; i++) { for(int j = i + 1; j <= 7; j++) { System.out.println(i + "\t" + j); count++; } } System.out.println("Total groups number is…
public class Solution { public static void main(String[] args) { double randX; double randY; int hitCount = 0; for(int i = 0; i <= 1000000; i++) { randX = Math.random() * 200 - 100; randY = Math.random() * 200 - 100; if(randX < 0) hitCount++; if(ran…
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 second: "); int countDown = input.nextInt(); input.close(); long startTime =…
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a commission sought: "); int commissionSought = input.nextInt(); input.close(); double sum…
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter numbers: "); int max = 0; int count = 0; int number; while(true) { number = input.nextInt(…
public class Solution { public static void main(String[] args) { long positiveSide = 0; long negativeSide = 0; int side; for(long i = 0; i < 1000000; i++) { side = (int)(Math.random() * 2); if(side == 1) positiveSide++; else negativeSide++; } System.…
public class Solution { public static void main(String[] args) { double sum; double baseSalary = 5000; int i = 0; double prize = 0; while(true) { if(i <= 5000) prize = i * 0.08; else if(i <= 10000) prize = i * 0.1; else prize = i * 0.12; i++; sum =…
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter an integer: "); int number = input.nextInt(); input.close(); String[] charOfNumber = {&quo…
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the integer: "); int number = input.nextInt(); input.close(); String binaryString = "…
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the ISBN: "); String isbn = input.nextLine(); input.close(); int numberOfISDN = Integer.pa…
public class Solution { public static void main(String[] args) { double sum = 0; for(int i = 1; i <= 624; i++) { sum += 1.0 / (Math.sqrt(i) + Math.sqrt(i + 1)); } System.out.println(sum); } }…
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); int playerWin = 0; int computerWin = 0; while(true) { if(playerWin == 2 || computerWin == 2) break; System.out.print("s…
public class Solution { public static void main(String[] args) { int sum; for(int i = 6; i < 10000; i++) { sum = 0; for(int j = 1; j < i; j++) if(i % j == 0) sum += j; if(sum == i) System.out.print(i + " "); } } }…
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter your lottery pick (two digits): "); int guess = input.nextInt(); int lottery = (int)(Math.…
public class Solution { public static void main(String[] args) { int n = 0; while(n * n < 12000) { n++; } System.out.println(n); } }…
public class Solution { public static void main(String[] args) { int count = 0; for(int i = 100; i <= 1000; i++) { if(i % 5 == 0 ^ i % 6 == 0) { System.out.print(i + " "); count++; if(count == 10) { System.out.println(); count = 0; } } } } }…
public class Solution { public static void main(String[] args) { int count = 0; for(int i = 100; i <= 1000; i++) { if(i % 5 == 0 && i % 6 == 0) { System.out.print(i + " "); count++; if(count == 10) { System.out.println(); count = 0; }…
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 students: "); int numberOfStudents = input.nextInt(); int score = 0; int max…
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 students: "); int numberOfStudents = input.nextInt(); int score = 0; int max…
public class Solution { public static void main(String[] args) { double rate = 0.05; double balance = 10000; double sum = 0; for(int i = 0; i < 10; i++) balance = balance * (1 + rate); System.out.println("The cost after 10 years is " + balanc…
public class Solution { public static void main(String[] args) { final double MILES_PER_KILOGRAM = 1.609; System.out.println("Miles" + "\t" + "Kilograms" + "\t" + "Kilograms" + "\t" + "Miles…
public class Solution { public static void main(String[] args) { final double POUNDS_PER_KILOGRAM = 2.2; System.out.println("Kilograms" + "\t" + "Pounds" + "\t" + "Pounds" + "\t" + "Kilogram…
public class Solution { public static void main(String[] args) { final double POUND_PER_KILOGRAM = 2.2; System.out.println("KILOGRAM" + "\t" + "POUND"); for(int i = 1; i < 200; i += 2) System.out.println(i + "\t"…
public class Solution { public static void main(String[] args) { final double KILOMETERS_PER_MILE = 1.609; System.out.println("Miles"+ "\t" + "Kilometers"); for(int i = 1; i <= 10; i++) System.out.println(i + "\t"…
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); int correctCount = 0; int answer = 0; int number1; int number2; long startTime = System.currentTimeMillis(); for(int i…
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter an int value, the program exits if the input is 0: "); int inputValue = input.nextInt(); i…
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the balance: "); double balance = input.nextDouble(); System.out.print("Enter the ann…
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the balance amount: "); double balance = input.nextDouble(); System.out.print("Enter…
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(); System.out.print("Enter the weekday of the…