Skip to content

Commit ecdd41c

Browse files
committed
Reorganization.
1 parent d5ec695 commit ecdd41c

14 files changed

+292
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package lesson01_basic_syntax.lab;
2+
3+
import java.util.Scanner;
4+
5+
public class N01StudentInformation {
6+
7+
public static void main(String[] args) {
8+
Scanner scanner = new Scanner(System.in);
9+
String name = scanner.nextLine();
10+
int age = Integer.parseInt(scanner.nextLine());
11+
double grade = Double.parseDouble(scanner.nextLine());
12+
System.out.printf("Name: %s, Age: %d, Grade: %.2f", name, age, grade);
13+
}
14+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package lesson01_basic_syntax.lab;
2+
3+
import java.util.Scanner;
4+
5+
public class N02Passed {
6+
public static void main(String[] args) {
7+
Scanner scanner = new Scanner(System.in);
8+
double grade = Double.parseDouble(scanner.nextLine());
9+
if (grade >= 3) {
10+
System.out.println("Passed!");
11+
}
12+
}
13+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package lesson01_basic_syntax.lab;
2+
3+
import java.util.Scanner;
4+
5+
public class N03PassedOrFailed {
6+
public static void main(String[] args) {
7+
Scanner scanner = new Scanner(System.in);
8+
double grade = Double.parseDouble(scanner.nextLine());
9+
if (grade > 2.99) {
10+
System.out.println("Passed!");
11+
} else {
12+
System.out.println("Failed!");
13+
}
14+
}
15+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package lesson01_basic_syntax.lab;
2+
3+
import java.util.Scanner;
4+
5+
public class N04BackIn30Minutes {
6+
public static void main(String[] args) {
7+
Scanner scanner = new Scanner(System.in);
8+
int hour = scanner.nextInt();
9+
int minute = scanner.nextInt();
10+
minute += 30;
11+
12+
if (minute > 59) {
13+
minute %= 60;
14+
hour++;
15+
}
16+
17+
if (hour > 23) {
18+
hour %= 24;
19+
}
20+
21+
if (minute < 10) {
22+
System.out.printf("%d:0%d", hour, minute);
23+
} else {
24+
System.out.printf("%d:%d", hour, minute);
25+
}
26+
}
27+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package lesson01_basic_syntax.lab;
2+
3+
import java.util.Scanner;
4+
5+
public class N05MonthPrinter {
6+
public static void main(String[] args) {
7+
Scanner scanner = new Scanner(System.in);
8+
int number = scanner.nextInt();
9+
switch (number) {
10+
case 1:
11+
System.out.println("January");
12+
break;
13+
case 2:
14+
System.out.println("February");
15+
break;
16+
case 3:
17+
System.out.println("March");
18+
break;
19+
case 4:
20+
System.out.println("April");
21+
break;
22+
case 5:
23+
System.out.println("May");
24+
break;
25+
case 6:
26+
System.out.println("June");
27+
break;
28+
case 7:
29+
System.out.println("July");
30+
break;
31+
case 8:
32+
System.out.println("August");
33+
break;
34+
case 9:
35+
System.out.println("September");
36+
break;
37+
case 10:
38+
System.out.println("October");
39+
break;
40+
case 11:
41+
System.out.println("November");
42+
break;
43+
case 12:
44+
System.out.println("December");
45+
break;
46+
default:
47+
System.out.println("Error!");
48+
break;
49+
}
50+
}
51+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package lesson01_basic_syntax.lab;
2+
3+
import java.util.Scanner;
4+
5+
public class N06ForeignLanguages {
6+
public static void main(String[] args) {
7+
Scanner scanner = new Scanner(System.in);
8+
String country = scanner.nextLine();
9+
switch (country) {
10+
case "England":
11+
case "USA":
12+
System.out.println("English");
13+
break;
14+
case "Spain":
15+
case "Argentina":
16+
case "Mexico":
17+
System.out.println("Spanish");
18+
break;
19+
default:
20+
System.out.println("unknown");
21+
}
22+
}
23+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package lesson01_basic_syntax.lab;
2+
3+
import java.util.Scanner;
4+
5+
public class N07TheatrePromotions {
6+
public static void main(String[] args) {
7+
Scanner scanner = new Scanner(System.in);
8+
String day = scanner.nextLine();
9+
int age = scanner.nextInt();
10+
int ticketPrice = 0;
11+
12+
switch (day) {
13+
case "Weekday":
14+
if (age <= 18) {
15+
ticketPrice = 12;
16+
} else if (age <= 64) {
17+
ticketPrice = 18;
18+
} else if (age <= 122) {
19+
ticketPrice = 12;
20+
}
21+
break;
22+
case "Weekend":
23+
if (age <= 18) {
24+
ticketPrice = 15;
25+
} else if (age <= 64) {
26+
ticketPrice = 20;
27+
} else if (age <= 122) {
28+
ticketPrice = 15;
29+
}
30+
break;
31+
case "Holiday":
32+
if (age <= 18) {
33+
ticketPrice = 5;
34+
} else if (age <= 64) {
35+
ticketPrice = 12;
36+
} else if (age <= 122) {
37+
ticketPrice = 10;
38+
}
39+
break;
40+
}
41+
42+
if (age < 0 || age > 122) {
43+
System.out.println("Error!");
44+
} else {
45+
System.out.printf("%d$", ticketPrice);
46+
}
47+
}
48+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package lesson01_basic_syntax.lab;
2+
3+
public class N08DivisibleByThree {
4+
public static void main(String[] args) {
5+
int divisor = 3;
6+
for (int i = 1; i < 101; i++) {
7+
if (i % divisor == 0) {
8+
System.out.println(i);
9+
}
10+
}
11+
}
12+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package lesson01_basic_syntax.lab;
2+
3+
import java.util.Scanner;
4+
5+
public class N09SumOfOddNumbers {
6+
public static void main(String[] args) {
7+
Scanner scanner = new Scanner(System.in);
8+
int n = scanner.nextInt();
9+
int sum = 0;
10+
int counter = 0;
11+
int number = 1;
12+
while (counter < n) {
13+
System.out.println(number);
14+
sum += number;
15+
number += 2;
16+
counter++;
17+
}
18+
System.out.printf("Sum: %d", sum);
19+
}
20+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package lesson01_basic_syntax.lab;
2+
3+
import java.util.Scanner;
4+
5+
public class N10MultiplicationTable {
6+
public static void main(String[] args) {
7+
Scanner scanner = new Scanner(System.in);
8+
int number = scanner.nextInt();
9+
for (int i = 1; i < 11; i++) {
10+
System.out.printf("%d X %d = %d",
11+
number,
12+
i,
13+
number * i);
14+
System.out.println();
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)