Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variables #3

Open
github-learning-lab bot opened this issue Jun 2, 2022 · 1 comment
Open

Variables #3

github-learning-lab bot opened this issue Jun 2, 2022 · 1 comment

Comments

@github-learning-lab
Copy link

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?

Scanner keyboard = new Scanner (System.in); 

String firstName; // User's first name
String itemOrder; // Item ordered
String frostingType; // Frosting ordered
String fillingType; // Filling ordered
String toppings; // Toppings ordered
String input;  // User input

double cost = 15.00; // Cost of cake and cupcakes
final double TAX_RATE = .08;  // Sales tax rate
double tax; // Amount of tax

Add in the following comment and line of code to print friendly messages:

// Introduce shop and prompt user to input first name

System.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.

@Dy-tech
Copy link

Dy-tech commented Jun 2, 2022

I do!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant