moved small projects into one project folder

This commit is contained in:
Cameron Seamons 2026-01-04 18:56:38 -07:00
parent 5f73e9e26b
commit 7a90c4c23f
4 changed files with 116 additions and 2 deletions

View file

@ -0,0 +1,7 @@
public class Main {
public static void main(String[] args) {
}
}

View file

@ -0,0 +1,62 @@
import java.util.Scanner;
public class ifStatements {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String name;
int age;
String isStudent;
System.out.print("Enter your name: ");
name = scanner.nextLine();
System.out.print("Enter your age: ");
age = scanner.nextInt();
scanner.nextLine();
System.out.print("Are you a student (true/false): ");
isStudent = scanner.nextLine();
// Check if user entered a name
if(name.isEmpty()){
System.out.println("You didn't enter your name! 😡");
}
else{
// Capitalize their name
name = name.substring(0,1).toUpperCase() + name.substring(1).toLowerCase();
System.out.println("Hello " + name + "! 😀");
}
// Place user into their age group and respond accordingly
if(age >= 65){
System.out.println("You are a senior! 👴");
}
else if(age >= 18){
System.out.println("You are an adult! 🧑");
}
else if(age < 0){
System.out.println("You haven't been born yet! 👼");
}
else if(age == 0){
System.out.println("You are a baby! 👶");
}
else{
System.out.println("You are a child! 🧒");
}
// normalize the student variable
String studentInput = isStudent.trim().toLowerCase();
// Greet user as a student or not
if(studentInput.equals("true") || studentInput.equals("t")){
System.out.println("You are a student! 🏫");
}
else{
System.out.println("You are NOT a student 🏢");
}
scanner.close();
}
}

View file

@ -1,6 +1,6 @@
import java.util.Scanner; import java.util.Scanner;
public class Main { public class madLibs {
public static void main(String[] args){ public static void main(String[] args){
@ -23,7 +23,7 @@ public class Main {
System.out.print("Enter an adjective (description): "); System.out.print("Enter an adjective (description): ");
adjective3 = scanner.nextLine(); adjective3 = scanner.nextLine();
System.out.println("Today I went to a " + adjective1 + " zoo"); System.out.println("\nToday I went to a " + adjective1 + " zoo");
System.out.println("In an exhibit, I saw a " + noun1 + "."); System.out.println("In an exhibit, I saw a " + noun1 + ".");
System.out.println(noun1 + " was " + adjective2 + " and " + verb1 + "!"); System.out.println(noun1 + " was " + adjective2 + " and " + verb1 + "!");
System.out.println("I was " + adjective3 + "!"); System.out.println("I was " + adjective3 + "!");

View file

@ -0,0 +1,45 @@
import java.util.Scanner;
public class shoppingCart {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
// Declare variables
String item;
double price;
int quantity;
double total;
// Get item from User
System.out.print("What item would you like to buy?: ");
item = scanner.nextLine();
// Get price from User
System.out.print("What is the price for each?: ");
price = scanner.nextDouble();
// Get quantity from User
System.out.print("How many would you like?: ");
quantity = scanner.nextInt();
// Calculate total
total = price * quantity;
// Print out their order
// Check if one item or more to give correct print statement
if (quantity == 1) {
System.out.println("\nYou have bought " + quantity + " " + item);
}
else {
System.out.println("You have bought " + quantity + " " + item + "s");
}
// Print their total
System.out.println("Your total is $" + total);
scanner.close();
}
}