← Back to Week 1 Hub

VariableApp + Receipt

Operators exercise — declare variables of different types, print them, and calculate a total

string-application
In Plain English

This project has two small programs. VariableApp: pick different types of information about yourself and print each one. Receipt: calculate the total cost of buying multiple of the same item.

What a Successful Run Looks Like
VariableApp.java
My favorite color is: Blue The year I started this class is: 2025 My middle initial is: M Do I have pets? true There are 7 days in a week. The price of coffee is $4.99

Your values will be different — pick your own color, year, initial, and so on.

Receipt.java
You bought 3 Apples for $7.11

Your item, quantity, and price will differ — the total should equal price × quantity.

What This Exercise Practices
Flow Diagram
VariableApp.java
Declare variables
Assign values
Print each with a message
Receipt.java
Set item name, price & quantity
Calculate total
Print result
Tip: VariableApp has two parts — first you declare variables without initial values, then you declare and initialize more variables. Make sure you cover both.

Workbook 1c · p.69-70

← Shopping List Math Application →