Uploaded December 2024 | Updated September 2026, 2 weeks ago
#java #javatutorial #javacourse
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// SHOPPING CART PROGRAM
Scanner scanner = new Scanner(System.in);
String item;
double price;
int quantity;
char currency = '$';
double total;
System.out.print("What item would you like to buy?: ");
item = scanner.nextLine();
System.out.print("What is the price for each?: ");
price = scanner.nextDouble();
System.out.print("How many would you like?: ");
quantity = scanner.nextInt();
total = price * quantity;
System.out.println("\nYou have bought " + quantity + " " + item +"/s");
System.out.println("Your total is " + currency + total);
scanner.close();
}
}
#java #javatutorial #javacourse
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// SHOPPING CART PROGRAM
Scanner scanner = new Scanner(System.in);
String item;
double price;
int quantity;
char currency = '$';
double total;
System.out.print("What item would you like to buy?: ");
item = scanner.nextLine();
System.out.print("What is the price for each?: ");
price = scanner.nextDouble();
System.out.print("How many would you like?: ");
quantity = scanner.nextInt();
total = price * quantity;
System.out.println("\nYou have bought " + quantity + " " + item +"/s");
System.out.println("Your total is " + currency + total);
scanner.close();
}
}
![Learn Java anonymous classes in 5 minutes! 🕵️♂️
#java #javatutorial #javacourse
public class Main {
public static void main(String[] args) {
// Anonymous class = A class that doesnt have a name. Cannot be reused.
// Add custom behavior without having to create a new class.
// Often used for one time uses (TimerTask, Runnable, callbacks)
Dog dog1 = new Dog();
Dog dog2 = new Dog(){
@Override
void speak(){
System.out.println(Scooby Doo says *Ruh Roh*);
}
};
dog1.speak();
dog2.speak();
}
}
public class Dog {
void speak(){
System.out.println(The dog goes *woof*);
}
} Learn Java anonymous classes in 5 minutes! 🕵️♂️](https://i.ytimg.com/vi/P_iOnmdww8E/mqdefault.jpg)

![How to WRITE FILES with Java in 8 minutes! ✍
#java #javatutorial #javacourse
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
public class Main {
public static void main(String[] args) {
// How to write a file using Java (4 popular options)
// FileWriter = Good for small or medium-sized text files
// BufferedWriter = Better performance for large amounts of text
// PrintWriter = Best for structured data, like reports or logs
// FileOutputStream = Best for binary files (e.g., images, audio files)
String filePath = test.txt;
String textContent =
Roses are Red
Violets are Blue
BOOTY BOOTY BOOTY
ROCKIN EVERWHERE!
;
try(FileWriter writer = new FileWriter(filePath)){
writer.write(textContent);
System.out.println(File has been written);
}
catch(FileNotFoundException e){
System.out.println(Could not locate file location);
}
catch(IOException e){
System.out.println(Could not write file);
}
}
} How to WRITE FILES with Java in 8 minutes! ✍](https://i.ytimg.com/vi/Pg0aoSbrqOE/mqdefault.jpg)


![Java arithmetic is easy! 🧮
#java #javatutorial #javacourse
public class Main {
public static void main(String[] args) {
// Arithmetic Operators
int x = 10;
int y = 2;
int z;
z = x + y; // ADDITION
z = x - y; // SUBTRACTION
z = x * y; // MULTIPLICATION
z = x / y; // DIVISION
z = x % y; // MODULUS
System.out.println(z);
}
} Java arithmetic is easy! 🧮](https://i.ytimg.com/vi/QAD5unRlCyo/mqdefault.jpg)


![Learn Java 2D arrays in 9 minutes! ⬜
#java #javatutorial #javacourse
public class Main {
public static void main(String[] args){
// 2D array = An array where each element is an array
// Useful for storing a matrix of data
//
// EXAMPLE 1
//
String[][] groceries = {{apple, orange, banana},
{potato, onion, carrot},
{chicken, pork, beef, fish}};
groceries[2][1] = eggs;
for(String[] foods : groceries){
for(String food : foods){
System.out.print(food + );
}
System.out.println();
}
//
// EXAMPLE 2
//
char[][] telephone = {{1, 2, 3},
{4, 5, 6},
{7, 8, 9},
{*, 0, #}};
for(char[] row : telephone){
for(char number : row){
System.out.print(number + );
}
System.out.println();
}
}
} Learn Java 2D arrays in 9 minutes! ⬜](https://i.ytimg.com/vi/Qf3Nczxm2AY/mqdefault.jpg)
![Random numbers in NumPy are easy! 🎲
#coding #python #numpy
Random numbers in NumPy are useful for simulations,
modeling, applying random transformations, and testing purposes.
rng = np.random.default_rng()
print(rng.integers(low=1, high=7, size=(3, 4))) # 3x4 array of Ints
np.random.seed()
print(np.random.uniform(low 1, high=1, size=(3, 2))) # floats between 2 values
# Shuffle
array = np.array([1, 2, 3, 4, 5])
rng.shuffle(array)
print(array)
# Random Choice
fruits = np.array([🍎, 🍊, 🍌, 🥥, 🍍])
print(rng.choice(fruits, size=(3, 3))) Random numbers in NumPy are easy! 🎲](https://i.ytimg.com/vi/Ql5zGPtxlHY/mqdefault.jpg)
![User input in Java is easy! ⌨️
#java #javatutorial #javacourse
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println(Enter your name: );
String name = scanner.nextLine();
System.out.println(Enter your age: );
int age = scanner.nextInt();
System.out.println(What is your gpa: );
double gpa = scanner.nextDouble();
System.out.println(Are you a student? (true/false): );
boolean isStudent = scanner.nextBoolean();
System.out.println(Hello + name);
System.out.println(You are + age + years old);
System.out.println(Your gpa is: + gpa);
if(isStudent){
System.out.println(You are enrolled in classes);
}
else{
System.out.println(You are NOT enrolled in classes);
}
scanner.close();
}
} User input in Java is easy! ⌨️](https://i.ytimg.com/vi/RAthlOQUMkc/mqdefault.jpg)