kristofer / Python Alarm
0 likes
0 forks
1 files
Last active
1 | from datetime import datetime |
2 | from playsound import playsound |
3 | alarm_time = input("Enter the time of alarm to be set:HH:MM:SS\n") |
4 | alarm_hour=alarm_time[0:2] |
5 | alarm_minute=alarm_time[3:5] |
6 | alarm_seconds=alarm_time[6:8] |
7 | alarm_period = alarm_time[9:11].upper() |
8 | print("Setting up alarm..") |
9 | while True: |
10 | now = datetime.now() |
kristofer / Acronym Python
0 likes
0 forks
1 files
Last active
user_input = str(input("Enter a Phrase: "))
text = user_input.split()
a = " "
for i in text:
a = a+str(i[0]).upper()
print(a)
kristofer / Acronym Python
0 likes
0 forks
1 files
Last active
user_input = str(input("Enter a Phrase: "))
text = user_input.split()
a = " "
for i in text:
a = a+str(i[0]).upper()
print(a)
kristofer / Linear Search Java
0 likes
0 forks
1 files
Last active
public class LinearSearch {
// Method that performs linear search
public static int linearSearch(int[] array, int target) {
// Iterate through each element in the array
for (int i = 0; i < array.length; i++) {
// If current element matches target, return its index
if (array[i] == target) {
return i;
}
kristofer / Java Strings Intro
0 likes
0 forks
1 files
Last active
Basic Intro to Java String class.
Working with Strings in Java
String Creation and Basics
Strings are immutable objects in Java. Here are different ways to create them:
public class StringBasics {
public static void main(String[] args) {
// String creation
kristofer / Java Intro level 0
0 likes
0 forks
1 files
Last active
Very VERY Basic Introduction to Java Programming
VERRRRRRY Basic Introduction to Java Programming
1. Basic Program Structure
Every Java program starts with a class, and the main method is the entry point of the program. Here's a simple example:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
kristofer / Java Control Flow: If Statements and Loops
0 likes
0 forks
1 files
Last active
Java Control Flow: If Statements and Loops
Java Control Flow: If Statements and Loops
If Statements
Basic If Statement
The simplest form of decision making:
public class BasicIf {
public static void main(String[] args) {
kristofer / Vars, Ops and Types
0 likes
0 forks
1 files
Last active
Java Variables, Operators, and Types
Java Variables, Operators, and Types
Primitive Data Types
Java has eight primitive data types that store simple values. Here's a comprehensive overview:
public class PrimitiveTypes {
public static void main(String[] args) {
// Integer types
byte smallNumber = 127; // 8-bit, range: -128 to 127
kristofer / Jshell Snippets 1
0 likes
0 forks
1 files
Last active
1 | List<String> list1 = new ArrayList<>(); |
2 | list1.add("Kristofer"); |
3 | // new Scanner(System.in).next(); |
4 | // input("Howdy"); |
5 | |
6 | |
7 | String input(String prompt) { |
8 | System.out.print(prompt+" "); |
9 | var sc = new Scanner(System.in); |
10 | return sc.next(); |