-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 74b4e2e
Showing
25 changed files
with
522 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package DataTypesandVariables; | ||
|
||
import java.util.Scanner; | ||
|
||
public class ConvertMeterstoKilometers { | ||
public static void main(String[] args) { | ||
Scanner scanner = new Scanner(System.in); | ||
|
||
int meters = Integer.parseInt(scanner.nextLine()); | ||
double km = meters / 1000.0; | ||
|
||
System.out.printf("%.2f", km); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package DataTypesandVariables; | ||
|
||
import java.util.Scanner; | ||
|
||
public class F01IntegerOperations { | ||
public static void main(String[] args) { | ||
Scanner scanner = new Scanner(System.in); | ||
int first = Integer.parseInt(scanner.nextLine()); | ||
int second = Integer.parseInt(scanner.nextLine()); | ||
int third = Integer.parseInt(scanner.nextLine()); | ||
int forth = Integer.parseInt(scanner.nextLine()); | ||
|
||
//int sum = first + second + third + forth; | ||
int result = ((first + second) / third ) * forth; | ||
System.out.println(result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package DataTypesandVariables; | ||
|
||
import java.util.Scanner; | ||
|
||
public class F02SumDigits { | ||
public static void main(String[] args) { | ||
Scanner scanner = new Scanner(System.in); | ||
int number = Integer.parseInt(scanner.nextLine()); | ||
int sum = 0; | ||
|
||
while (number > 0) { | ||
|
||
int lastDigit = number % 10; | ||
sum += lastDigit; | ||
number /= 10; | ||
|
||
|
||
} | ||
System.out.println(sum); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package DataTypesandVariables; | ||
|
||
import java.util.Scanner; | ||
|
||
public class F02SumDigitsForString { | ||
public static void main(String[] args) { | ||
Scanner scanner = new Scanner(System.in); | ||
int number = Integer.parseInt(scanner.nextLine()); | ||
int sum = 0; | ||
String numberAsString = "" + number; | ||
for (int i = 0; i <= numberAsString.length() - 1; i++) { | ||
|
||
char currentSymbol = numberAsString.charAt(i); | ||
//char --> String --> int | ||
//'5' -> 5 | ||
int currentDigit = Integer.parseInt(currentSymbol + ""); | ||
sum += currentDigit; | ||
|
||
} | ||
|
||
System.out.println(sum); | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package DataTypesandVariables; | ||
|
||
import java.util.Scanner; | ||
|
||
public class F03Elevator { | ||
public static void main(String[] args) { | ||
Scanner scanner = new Scanner(System.in); | ||
int numberOfPeople = Integer.parseInt(scanner.nextLine()); | ||
int capacity = Integer.parseInt(scanner.nextLine()); | ||
|
||
// int courses = numberOfPeople / 3; | ||
// int courses1 = numberOfPeople % 3; | ||
// int all = 1 + courses; | ||
int courses = 0; | ||
if (numberOfPeople <= capacity){ | ||
courses = 1; | ||
} else if (numberOfPeople % capacity == 0) { | ||
courses = numberOfPeople / capacity; | ||
} else { | ||
courses = (numberOfPeople / capacity) + 1; | ||
} | ||
//int courses = (int) Ma | ||
|
||
System.out.println(courses); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package DataTypesandVariables; | ||
|
||
import java.util.Scanner; | ||
|
||
public class F04SumofChars { | ||
public static void main(String[] args) { | ||
Scanner scanner = new Scanner(System.in); | ||
int numberOfLines = Integer.parseInt(scanner.nextLine()); | ||
int sum = 0; | ||
|
||
// for (int i = 0; i < numberOfLines ; i++) { | ||
// char letter = scanner.nextLine().charAt(0); | ||
// int symbol = Integer.parseInt(letter + ""); | ||
// sum += symbol; | ||
//} | ||
// System.out.println(sum); | ||
for (int i = 0; i < numberOfLines ; i++) { | ||
char symbol = scanner.nextLine().charAt(0); | ||
int asciiCode =(int) symbol; | ||
//int asciiCode =symbol; | ||
|
||
sum += asciiCode; | ||
//sum += symbol; | ||
|
||
} | ||
System.out.println("The sum equals: " + sum); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package DataTypesandVariables; | ||
|
||
import java.util.Scanner; | ||
|
||
public class F05PrintPartOfASCIITable { | ||
public static void main(String[] args) { | ||
Scanner scanner = new Scanner(System.in); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package DataTypesandVariables; | ||
|
||
import java.util.Scanner; | ||
|
||
public class F10PokeMon { | ||
public static void main(String[] args) { | ||
Scanner scanner = new Scanner(System.in); | ||
int power = Integer.parseInt(scanner.nextLine()); | ||
int startPower = power; | ||
int distance = Integer.parseInt(scanner.nextLine()); | ||
int factor = Integer.parseInt(scanner.nextLine()); | ||
|
||
int count = 0; | ||
|
||
while (power >= distance) { | ||
|
||
power -= distance; | ||
count++; | ||
|
||
if (power == startPower / 2) { | ||
|
||
if (factor!=0) { | ||
power = power / factor; // power /= factor | ||
} | ||
} | ||
|
||
|
||
} | ||
System.out.println(power); | ||
System.out.println(count); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package DataTypesandVariables; | ||
|
||
import java.util.Scanner; | ||
|
||
public class F6TriplesofLatinLetters { | ||
public static void main(String[] args) { | ||
Scanner scanner = new Scanner(System.in); | ||
|
||
int n = Integer.parseInt(scanner.nextLine()); | ||
for (char i = 'a'; i < 'a' + n; i++) { | ||
//System.out.println(i); | ||
for (char j = 'a'; j < 'a' + n; j++) { | ||
|
||
//System.out.println(j); | ||
for (char k = 'a'; k < 'a' + n; k++) { | ||
|
||
System.out.printf("%c%c%c%n",i,j,k); | ||
|
||
|
||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package DataTypesandVariables; | ||
|
||
import java.util.Scanner; | ||
|
||
public class F7WaterOverflow { | ||
public static void main(String[] args) { | ||
Scanner scanner = new Scanner(System.in); | ||
int numberOfLines = Integer.parseInt(scanner.nextLine()); | ||
int tank = 0; | ||
|
||
for (int i = 0; i < numberOfLines ; i++) { | ||
|
||
int quantities = Integer.parseInt(scanner.nextLine()); | ||
tank +=quantities; | ||
if (tank > 255) { | ||
System.out.println("Insufficient capacity!"); | ||
tank -=quantities; | ||
continue; | ||
|
||
} | ||
|
||
|
||
} | ||
|
||
System.out.println(tank); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package DataTypesandVariables; | ||
|
||
import java.util.Scanner; | ||
|
||
public class F8BeerKegs { | ||
public static void main(String[] args) { | ||
Scanner scanner = new Scanner(System.in); | ||
int countKegs = Integer.parseInt(scanner.nextLine()); | ||
double maxVolume = Double.MIN_VALUE; //or 0 | ||
String maxModel = ""; | ||
|
||
for (int i = 0; i < countKegs; i++) { | ||
String model = scanner.nextLine(); | ||
double radius = Double.parseDouble(scanner.nextLine()); | ||
int height = Integer.parseInt(scanner.nextLine()); | ||
|
||
double volume = Math.PI * height * (radius * radius); | ||
|
||
if (volume > maxVolume) { | ||
maxVolume = volume; | ||
maxModel = model; | ||
} | ||
|
||
} | ||
System.out.println(maxModel); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 dobromirtt1 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package DataTypesandVariables; | ||
|
||
import java.math.BigDecimal; | ||
import java.util.Scanner; | ||
|
||
public class P03ExactSumofRealNumbers { | ||
|
||
public static void main(String[] args) { | ||
Scanner scanner = new Scanner(System.in); | ||
|
||
int n = Integer.parseInt(scanner.nextLine()); | ||
BigDecimal sum = new BigDecimal(0); | ||
// double sum = 0; | ||
for (int i = 0; i < n; i++) { | ||
//double currentNum = Double.parseDouble(scanner.nextLine()); | ||
// sum += currentNum; | ||
BigDecimal currentNum = new BigDecimal(scanner.nextLine()); | ||
sum = sum.add(currentNum); | ||
|
||
} | ||
System.out.println(sum); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package DataTypesandVariables; | ||
|
||
import java.util.Scanner; | ||
|
||
public class P04TownInfo { | ||
public static void main(String[] args) { | ||
Scanner scanner = new Scanner(System.in); | ||
String townName = scanner.nextLine(); | ||
int population = Integer.parseInt(scanner.nextLine()); | ||
int area = Integer.parseInt(scanner.nextLine()); | ||
|
||
System.out.printf("Town %s has population of %d and area %d square km.", townName, population, area); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package DataTypesandVariables; | ||
|
||
import java.util.Scanner; | ||
|
||
public class P05ConcatNames { | ||
public static void main(String[] args) { | ||
Scanner scanner = new Scanner(System.in); | ||
String firstName = scanner.nextLine(); | ||
String secondName = scanner.nextLine(); | ||
String delimiter = scanner.nextLine(); | ||
|
||
String result = firstName + delimiter + secondName; | ||
//System.out.println(result); | ||
System.out.printf("%s%s%s", firstName, delimiter, secondName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package DataTypesandVariables; | ||
|
||
import java.util.Scanner; | ||
|
||
public class P06CharstoString { | ||
|
||
public static void main(String[] args) { | ||
Scanner scanner = new Scanner(System.in); | ||
|
||
char n1 = scanner.nextLine().charAt(0); | ||
char n2 = scanner.nextLine().charAt(0); | ||
char n3 = scanner.nextLine().charAt(0); | ||
|
||
System.out.printf("%s%s%s", n1, n2, n3); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package DataTypesandVariables; | ||
|
||
import java.util.Scanner; | ||
|
||
public class P07ReversedChars { | ||
|
||
public static void main(String[] args) { | ||
Scanner scanner = new Scanner(System.in); | ||
char firstSymbol = scanner.nextLine().charAt(0); | ||
char secondSymbol = scanner.nextLine().charAt(0); | ||
char thirdSymbol = scanner.nextLine().charAt(0); | ||
|
||
System.out.printf("%c %c %c", thirdSymbol, secondSymbol, firstSymbol); | ||
|
||
} | ||
} |
Oops, something went wrong.