Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Calculating Coffee Shop Revenue | Variables and Data Types
Introduction to Java

You are running a small coffee shop. Complete the program so it:

  1. Creates variables for:
    • The coffee shop name ("Bean Haven Cafe")
    • The number of coffees sold (24)
    • The price of one coffee (4.5)
    • The number of new customers (5)
  2. Uses arithmetic operators to calculate the total earnings.
  3. Uses the increment operator to increase the number of customers by 1.
  4. Prints the number of customers and the total earnings. Output should be as follows:
Total number of customers:
6
Total earnings:
108.0
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 2. Chapter 4
single

single

Challenge: Calculating Coffee Shop Revenue

Swipe to show menu

Task

Swipe to start coding

You are running a small coffee shop. Complete the program so it:

  1. Creates variables for:
    • The coffee shop name ("Bean Haven Cafe")
    • The number of coffees sold (24)
    • The price of one coffee (4.5)
    • The number of new customers (5)
  2. Uses arithmetic operators to calculate the total earnings.
  3. Uses the increment operator to increase the number of customers by 1.
  4. Prints the number of customers and the total earnings. Output should be as follows:
Total number of customers:
6
Total earnings:
108.0

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 2. Chapter 4
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt