You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this section, you will create a scanner object to take in user input, declare variables that will store information, and print out a friendly message!
You can comment out our 'Hello world' statement by adding // to the start of that line:
// System.out.println("Hello World!");
Type the following code under Step 2. It will create your scanner object, create your string variables that store text information, and double variables that store numeric values. Most of these variables don't have any values yet (except "cost" and "TAX_RATE"). We are just declairing their name and data type.
The Scanner object has pre-built methods we will use to process user input. Notice how we imported it at the top of the file?
Scannerkeyboard = newScanner (System.in);
StringfirstName; // User's first nameStringitemOrder; // Item orderedStringfrostingType; // Frosting orderedStringfillingType; // Filling orderedStringtoppings; // Toppings orderedStringinput; // User inputdoublecost = 15.00; // Cost of cake and cupcakesfinaldoubleTAX_RATE = .08; // Sales tax ratedoubletax; // Amount of tax
Add in the following comment and line of code to print friendly messages:
// Introduce shop and prompt user to input first nameSystem.out.println("Welcome to Java's Cake & Cupcake Shop!");
System.out.println("We make custom cakes with our secret cake batter!");
Before we test this code, remember to re-compile the java file javac custom_order.java
Then run the file with this command: java custom_order
If you see our friendly greeting in your terminal, add a comment to this issue.
The text was updated successfully, but these errors were encountered:
Variables
In this section, you will create a scanner object to take in user input, declare variables that will store information, and print out a friendly message!
You can comment out our 'Hello world' statement by adding // to the start of that line:
// System.out.println("Hello World!");
Type the following code under Step 2. It will create your scanner object, create your string variables that store text information, and double variables that store numeric values. Most of these variables don't have any values yet (except "cost" and "TAX_RATE"). We are just declairing their name and data type.
The Scanner object has pre-built methods we will use to process user input. Notice how we imported it at the top of the file?
Add in the following comment and line of code to print friendly messages:
Before we test this code, remember to re-compile the java file
javac custom_order.java
Then run the file with this command:
java custom_order
If you see our friendly greeting in your terminal, add a comment to this issue.
The text was updated successfully, but these errors were encountered: