Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit f21e2d8

Browse files
authored
Add files via upload
1 parent 5e044c3 commit f21e2d8

File tree

100 files changed

+3279
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+3279
-0
lines changed

bluebook/BlueBookChange.java

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package bluebook;
2+
3+
import java.io.BufferedReader;
4+
import java.io.IOException;
5+
import java.io.InputStreamReader;
6+
7+
public class BlueBookChange {
8+
public static void main(String[] args) throws IOException {
9+
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
10+
11+
int n = Integer.parseInt(in.readLine());
12+
int quarters = n / 25;
13+
int dimes = (n - (quarters * 25)) / 10;
14+
int nickels = (n - (quarters * 25) - (dimes * 10)) / 5;
15+
int pennies = n - (quarters * 25) - (dimes * 10) - (nickels * 5);
16+
String result = "";
17+
18+
if (n == 1) {
19+
result += n + " cent requires ";
20+
} else {
21+
result += n + " cents requires ";
22+
}
23+
24+
if (quarters == 1) {
25+
result += quarters + " quarter";
26+
}
27+
else if (quarters != 0) {
28+
result += quarters + " quarters";
29+
}
30+
31+
if (dimes == 1) {
32+
if (quarters != 0) {
33+
result += ", ";
34+
}
35+
result += dimes + " dime";
36+
}
37+
else if (dimes != 0) {
38+
if (quarters != 0) {
39+
result += ", ";
40+
}
41+
result += dimes + " dimes";
42+
}
43+
44+
if (nickels == 1) {
45+
if (dimes != 0 || quarters != 0) {
46+
result += ", ";
47+
}
48+
result += nickels + " nickel";
49+
}
50+
else if (nickels != 0) {
51+
if (dimes != 0 || quarters != 0) {
52+
result += ", ";
53+
}
54+
result += nickels + " nickels";
55+
}
56+
57+
if (pennies == 1) {
58+
if (nickels != 0 || dimes != 0 || quarters != 0) {
59+
result += ", ";
60+
}
61+
result += pennies + " cent";
62+
}
63+
else if (pennies != 0) {
64+
if (nickels != 0 || dimes != 0 || quarters != 0) {
65+
result += ", ";
66+
}
67+
result += pennies + " cents";
68+
}
69+
System.out.println(result + ".");
70+
}
71+
}

bluebook/BlueBookCost.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package bluebook;
2+
import java.io.BufferedReader;
3+
import java.io.IOException;
4+
import java.io.InputStreamReader;
5+
6+
public class BlueBookCost {
7+
public static void main(String[] args) throws IOException {
8+
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
9+
10+
int n = Integer.parseInt(in.readLine());
11+
int mass;
12+
int amount;
13+
double extra;
14+
15+
for (int i = 0; i < n; i++) {
16+
mass = Integer.parseInt(in.readLine());
17+
if (mass <= 30) {
18+
amount = 38;
19+
}
20+
else if (mass <= 50) {
21+
amount = 55;
22+
}
23+
else if (mass <= 100) {
24+
amount = 73;
25+
}
26+
else {
27+
extra = (mass - 100) / 50.0;
28+
amount = 73 + (int) (Math.ceil(extra)) * 24;
29+
}
30+
System.out.println(amount);
31+
}
32+
}
33+
}

bluebook/BlueBookCrossCountry.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package bluebook;
2+
import java.io.BufferedReader;
3+
import java.io.IOException;
4+
import java.io.InputStreamReader;
5+
6+
public class BlueBookCrossCountry {
7+
public static void main(String[] args) throws IOException {
8+
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
9+
10+
String code = in.readLine();
11+
12+
switch (code) {
13+
case "MG": {
14+
System.out.println("midget girls");
15+
break;
16+
}
17+
18+
case "MB": {
19+
System.out.println("midget boys");
20+
break;
21+
}
22+
23+
case "JG": {
24+
System.out.println("junior girls");
25+
break;
26+
}
27+
28+
case "JB": {
29+
System.out.println("junior boys");
30+
break;
31+
}
32+
33+
case "SG": {
34+
System.out.println("senior girls");
35+
break;
36+
}
37+
38+
case "SB": {
39+
System.out.println("senior boys");
40+
break;
41+
}
42+
43+
default: {
44+
System.out.println("invalid code");
45+
}
46+
}
47+
}
48+
}

bluebook/BlueBookDays.java

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package bluebook;
2+
import java.io.BufferedReader;
3+
import java.io.IOException;
4+
import java.io.InputStreamReader;
5+
6+
public class BlueBookDays {
7+
8+
public static boolean checkLeapYear(int year) {
9+
if (year % 4 == 0) {
10+
if (year % 100 == 0) {
11+
if (year % 400 == 0) {
12+
return true;
13+
} else {
14+
return false;
15+
}
16+
} else {
17+
return true;
18+
}
19+
} else {
20+
return false;
21+
}
22+
}
23+
24+
public static void main(String[] args) throws IOException {
25+
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
26+
27+
int testCases = Integer.parseInt(in.readLine());
28+
29+
int[] dayArray = new int[] {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
30+
31+
String[] input;
32+
int year, month, day;
33+
boolean isLeapYear;
34+
int dayCounter;
35+
36+
for (int i = 0; i < testCases; i++) {
37+
input = in.readLine().split(" ");
38+
year = Integer.parseInt(input[0]);
39+
month = Integer.parseInt(input[1]);
40+
day = Integer.parseInt(input[2]);
41+
isLeapYear = checkLeapYear(year);
42+
dayCounter = 0;
43+
44+
for (int j = 0; j < month - 1; j++) {
45+
if (j == 1 && isLeapYear) {
46+
dayCounter += 29;
47+
} else {
48+
dayCounter += dayArray[j];
49+
}
50+
}
51+
52+
dayCounter += day;
53+
System.out.println(dayCounter);
54+
}
55+
}
56+
57+
}

bluebook/BlueBookDigits.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package bluebook;
2+
import java.io.BufferedReader;
3+
import java.io.IOException;
4+
import java.io.InputStreamReader;
5+
6+
public class BlueBookDigits {
7+
8+
public static void main(String[] args) throws IOException {
9+
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
10+
11+
int n = Integer.parseInt(in.readLine());
12+
String[] number;
13+
int digits;
14+
15+
for (int i = 0; i < n; i++) {
16+
digits = 0;
17+
number = in.readLine().split("");
18+
for (int j = 0; j < number.length; j++) {
19+
if (!number[j].equals("-")) {
20+
digits++;
21+
}
22+
}
23+
System.out.println(digits);
24+
}
25+
}
26+
}

bluebook/BlueBookDigitsAndSums.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package bluebook;
2+
import java.io.BufferedReader;
3+
import java.io.IOException;
4+
import java.io.InputStreamReader;
5+
6+
public class BlueBookDigitsAndSums {
7+
public static void main(String[] args) throws IOException {
8+
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
9+
10+
String[] input = in.readLine().split(" ");
11+
int n1 = Integer.parseInt(input[0]);
12+
int n2 = Integer.parseInt(input[1]);
13+
int currentNum;
14+
int copyNum;
15+
int total;
16+
17+
for (int i = n1; i <= n2; i++) {
18+
total = 0;
19+
currentNum = i;
20+
copyNum = i;
21+
for (int j = 0; j < 3; j++) {
22+
total += (int) Math.pow(currentNum % 10, 3);
23+
currentNum /= 10;
24+
}
25+
if (total == copyNum) {
26+
System.out.println(i);
27+
}
28+
}
29+
}
30+
}

bluebook/BlueBookDirection.java

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package bluebook;
2+
import java.io.BufferedReader;
3+
import java.io.IOException;
4+
import java.io.InputStreamReader;
5+
6+
public class BlueBookDirection {
7+
public static void main(String[] args) throws IOException {
8+
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
9+
10+
int n = Integer.parseInt(in.readLine());
11+
int direction;
12+
String result;
13+
14+
for (int i = 0; i < n; i++) {
15+
direction = Integer.parseInt(in.readLine());
16+
if (direction >= 0 && direction <= 90) {
17+
if (direction <= 90 - direction) {
18+
result = "N";
19+
}
20+
else {
21+
result = "E";
22+
}
23+
}
24+
else if (direction >= 90 && direction <= 180) {
25+
if (direction - 90 <= 180 - direction) {
26+
result = "E";
27+
}
28+
else {
29+
result = "S";
30+
}
31+
}
32+
else if (direction >= 180 && direction <= 270) {
33+
if (direction - 180 <= 270 - direction) {
34+
result = "S";
35+
}
36+
else {
37+
result = "W";
38+
}
39+
}
40+
else {
41+
if (direction - 270 <= 360 - direction) {
42+
result = "W";
43+
}
44+
else {
45+
result = "N";
46+
}
47+
}
48+
System.out.println(result);
49+
}
50+
}
51+
}

bluebook/BlueBookEquation.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package bluebook;
2+
import java.io.BufferedReader;
3+
import java.io.IOException;
4+
import java.io.InputStreamReader;
5+
6+
public class BlueBookEquation {
7+
8+
public static void main(String[] args) throws IOException {
9+
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
10+
11+
double first = Double.parseDouble(in.readLine());
12+
double second = Double.parseDouble(in.readLine());
13+
14+
if (first == 0 && second == 0) {
15+
System.out.println("indeterminate");
16+
} else if (first == 0 && second != 0) {
17+
System.out.println("undefined");
18+
} else {
19+
System.out.printf("%.2f%n", -second / first);
20+
}
21+
}
22+
}

bluebook/BlueBookExactDivisors.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package bluebook;
2+
import java.io.BufferedReader;
3+
import java.io.IOException;
4+
import java.io.InputStreamReader;
5+
6+
public class BlueBookExactDivisors {
7+
public static void main(String[] args) throws IOException {
8+
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
9+
10+
int n = Integer.parseInt(in.readLine());
11+
12+
for (int i = 1; i <= (int) Math.sqrt(n); i++) {
13+
if (n % i == 0) {
14+
System.out.println(i);
15+
if (n / i != i) {
16+
System.out.println(n / i);
17+
}
18+
}
19+
}
20+
}
21+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package bluebook;
2+
import java.io.BufferedReader;
3+
import java.io.IOException;
4+
import java.io.InputStreamReader;
5+
6+
public class BlueBookFindTheCharacter {
7+
public static void main(String[] args) throws IOException {
8+
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
9+
10+
char ch = in.readLine().toLowerCase().charAt(0);
11+
String input = in.readLine();
12+
int counter = 0;
13+
14+
for (int i = 0; i < input.length(); i++) {
15+
if (input.toLowerCase().charAt(i) == ch) {
16+
counter++;
17+
}
18+
}
19+
System.out.println(input);
20+
System.out.println(counter);
21+
}
22+
}

0 commit comments

Comments
 (0)