You are on page 1of 1

Lab 


 
In this lab you will again need to create your own java program that will test what you have 
learned about variables in this chapter. You program will first prompt the user for the name, 
quantity, and price of an item.  It will then ask the user for the tax rate in your area (.06, .045, 
etc.).  Finally, your program should print out this information along with a subtotal (item price * 
quantity), amount of tax (subtotal * tax rate), and finally a grand total (subtotal + amount of tax). 
This will test your knowledge of variables and how to work with them.  Be sure to choose a 
proper type of variable for each value you need to save and work with. For example, item might 
be saved as an int type variable because item quantity is only whole numbers.  When 
completed successfully, the output of your program should look something like the screenshot 
below. 
 
 

 
Tips: 
 
­You will need to use a Scanner to get input from the user. 
 
­Don’t forget to check for missed semicolons, brackets, and quotation marks. 
 
­If you are getting errors when you go to compile your code, sometimes the error message itself 
can be very helpful for solving your problem.  For example if you get an “incompatible types” 
error, go back and check the data types of the variables involved. 
 
­Don’t worry if you try and still can’t find your error, you can watch the Lab 3 Solution video for a 
step by step walk through of a possible solution. 
 
Good Luck! 
 

You might also like