Java Bootcamp – Workbooks and Challenges
)}

Workbook 3.2

From Java-Bootcamp-Resources -> Module 1 -> 3. Booleans and Conditionals, open Workbook 3.2.

1. Shopping at the JavaMart


You walk in with 100 dollars, and your kids want the toy car for $5.99.

public class JavaMart { public static void main(String[] args) { double wallet = 100; double toyCar = 5.99; System.out.println("Can I get this car?"); } }

if you have enough money:

  • print: Sure!

  • Then, pay for the toy car. Your wallet value should decrease from the price you paid.

else:

  • print: Sorry I only have <wallet> left.

Nike shoes

One of your kids will ask for Nike shoes. They are $95.99.

double nike = 95.99; System.out.println("Can I get these nike shoes?");

if you have enough money to buy the shoes:

  • print: Sure!

  • Then, pay for the new shoes. Your wallet value should decrease from the price you paid.

else:

  • print: Sorry I only have <wallet> left.

Run your code.


Good Luck!


Feedback Summary
4.8
39 students
5

92%
4

3%
3

0%
2

0%
1

5%
Written Reviews
There are no written reviews yet.