Spr2018_CPS150_03_test1_key.pdf - CPS 150.03 First Test(Closed No Reference Material Allowed Spring 2018 Please Print Name Clearly KEY Complete the

# Spr2018_CPS150_03_test1_key.pdf - CPS 150.03 First...

This preview shows page 1 - 3 out of 3 pages.

CPS 150.03 First Test ( Closed: No Reference Material Allowed ) Spring 2018 Please Print Name Clearly: KEY Page 1 of 3 Complete the following program by adding code where indicated by comments: /** * Question1 : 3 * int, 3 * double ; 3 * int, 6 * double * * This program outputs a bill for three items. * The user inputs the quantity and price for each item. * The program computes subtotal, the amount of tax (at 6.25%), and * the total for all items plus tax. * * example: * * input: * Quantity of item 1: 3 * Price of item 1: 2.99 * Quantity of item 2: 5 * Price of item 2: 1.49 * Quantity of item 3: 1 * Price of item 3: 8.69 * output: * Item 1: 3 items at \$2.99 each * Item 2: 5 items at \$1.49 each * Item 3: 1 items at \$8.69 each * * Subtotal: 25.11 * 6.25 percent sales tax: \$1.57 * Total: \$26.68 */ import java.util.Scanner; public class Question1 { public static void main(String[] args) {
CPS 150.03 First Test ( Closed: No Reference Material Allowed ) Spring 2018 Please Print Name Clearly: KEY Page 2 of 3 Scanner kbd = new Scanner(System.in); /* * 1. Declare a named constant SALESTAX, ( 20 points ) * initialized to 0.0625 */ final double SALESTAX = 0.0625; /* * 2. Add variable declarations.

#### You've reached the end of your free preview.

Want to read all 3 pages?

• Fall '09
• \$2.99, \$1.57, \$1.49, \$8.69, \$26.68