Skip to content

ManfredasMileris/exercises-week1

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation

Exercise for Week 1: Coffee Time! ☕🌟

Objective:

Today, you'll get your hands on basic Java concepts like data types, string methods, and conditionals through a fun and simple coffee-themed exercise.

Background:

Imagine you're helping to program a digital display for a coffee shop. This display shows different messages based on the coffee type.

Task:

You will create a simple Java program that prints a message for each type of coffee. This will help you understand how to use strings and conditionals.

Requirements:

  1. Data Types: Use the String data type to store types of coffee.
  2. String Methods: Use string methods to manipulate and display text.
  3. Conditionals: Use if-else statements to decide what message to print based on the coffee type.

Instructions:

  1. Create a variable to store the type of coffee. Assume the coffee type is "Latte" for now.
  2. Use an if-else statement to check the type of coffee:
    • If it's "Espresso", print a message saying it's strong.
    • If it's "Americano", print a message noting it's a classic choice.
    • If it's "Latte", print a message about it being creamy and delicious.

Tasks:

  • Try changing the coffeeType variable to different options and see what messages print.
  • Think about how you might use string methods like toLowerCase() or toUpperCase() to make the input more flexible.

Exercise 2: Coffee Strength Calculator

Objective:

Learn to use arithmetic operators to calculate the strength of the coffee based on user preferences.

Instructions:

  1. Define variables for coffee base (amount of coffee in grams) and water ratio.
  2. Calculate the strength by dividing the coffee base by the water ratio.
  3. Print out the strength with a suitable message.

Exercise 3: Coffee Temperature Warning

Objective:

Use relational operators to warn the user if the coffee might be too hot to drink immediately.

Instructions:

  1. Define a variable for the temperature of the coffee.
  2. Use an if-else statement to check if the temperature is above a certain threshold and warn the user.

Exercise 4: Coffee Price Estimator

Objective:

Learn to use the addition and multiplication operators to estimate the price of a coffee order.

Instructions:

  1. Define variables for the number of coffees ordered and the price per cup.
  2. Calculate the total cost and print it.

Exercise 5: Coffee Type Counter

Objective:

Learn to use a for loop to iterate through an array of coffee orders and count how many of each type there are.

Instructions:

  1. Define an array of strings where each element is a type of coffee ordered by customers.
  2. Use a for loop to iterate through the array and count the number of each type of coffee.
  3. Print the counts for Espresso, Latte, and Americano.

Exercise 6: Coffee Replenish Reminder

Objective:

Use a while loop to simulate checking a coffee machine’s stock and remind to replenish if stock goes below a certain threshold.

Instructions:

  1. Start with a certain number of coffee pods.
  2. Use a while loop to decrease the number of coffee pods as they are used, one at a time.
  3. Print a reminder to replenish the pods when only 2 remain.

Exercise 7: Coffee Menu Printer

Objective:

Demonstrate a do-while loop by printing each type of coffee until the end of a list is reached.

Instructions:

  1. Define an array of coffee types like Espresso, Americano, Latte, and Cappuccino.
  2. Use a do-while loop to print each type until you've gone through the list.

Exercise 8: Coffee Flavor Enhancer

Objective:

Learn to use a for-each loop to iterate through an array of coffee additives and print a message for each.

Instructions:

  1. Define an array of additives such as "vanilla", "caramel", "cinnamon".
  2. Use a for-each loop to iterate through the array and suggest adding each to a coffee to enhance the flavor.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published