Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
justBeroe committed May 23, 2023
0 parents commit 74b4e2e
Show file tree
Hide file tree
Showing 25 changed files with 522 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
14 changes: 14 additions & 0 deletions ConvertMeterstoKilometers.java
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);
}
}
17 changes: 17 additions & 0 deletions F01IntegerOperations.java
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);
}
}
22 changes: 22 additions & 0 deletions F02SumDigits.java
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);

}
}
25 changes: 25 additions & 0 deletions F02SumDigitsForString.java
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);


}
}
26 changes: 26 additions & 0 deletions F03Elevator.java
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);
}
}
28 changes: 28 additions & 0 deletions F04SumofChars.java
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);
}
}
9 changes: 9 additions & 0 deletions F05PrintPartOfASCIITable.java
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);
}
}
32 changes: 32 additions & 0 deletions F10PokeMon.java
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);
}
}
24 changes: 24 additions & 0 deletions F6TriplesofLatinLetters.java
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);


}
}
}
}
}
28 changes: 28 additions & 0 deletions F7WaterOverflow.java
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);

}
}
27 changes: 27 additions & 0 deletions F8BeerKegs.java
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);
}
}
21 changes: 21 additions & 0 deletions LICENSE
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.
23 changes: 23 additions & 0 deletions P03ExactSumofRealNumbers.java
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);
}
}
14 changes: 14 additions & 0 deletions P04TownInfo.java
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);
}
}
16 changes: 16 additions & 0 deletions P05ConcatNames.java
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);
}
}
16 changes: 16 additions & 0 deletions P06CharstoString.java
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);
}
}
16 changes: 16 additions & 0 deletions P07ReversedChars.java
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);

}
}
Loading

0 comments on commit 74b4e2e

Please sign in to comment.