int a1 42 double b1 167312389 double c1 a1 b1 int a2 1123 double b2 1433 double

Int a1 42 double b1 167312389 double c1 a1 b1 int a2

This preview shows page 101 - 106 out of 106 pages.

int a1 = 42; double b1 = 1673.12389; double c1 = a1 * b1; int a2 = 1123; double b2 = 14.33; double c2 = a2 * b2; System.out.printf("Product 1: %6d %10.3f %12.3f \n", a1, b1, c1); System.out.printf("Product 2: %6d %10.3f %12.3f \n", a2, b2, c2); Output values in table format Product 1: ---- 42 -- 1673.124 --- 70271.203 Product 2: -- 1123 ---- 14.330 --- 16092.590 Blank padding is shown with a -
Image of page 101
N A M E G R D G P A B U G S B U N N Y 1 1 1 4 . 1 5 6 W Y L E E . C O Y O T E 7 0 7 . 3 1 2 R O A D R U N N E R 1 2 1 3 . 2 0 0 E L M E R F U D D 9 0 9 . 7 2 0 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 x 1 2 3 x x 1 2 3 4 5 6 0 – 15 scale System.out.printf(“%-16s %3d %06.3f %n”, name, grade, gpa);
Image of page 102
What is output by the following? System.out.printf(“%-10sX%3d %.3f”, “Plano”, 12, 392.29385); Plano-----X-12 392.294 Blank padding is shown with a -
Image of page 103
What is output by the following? double avg = 2.0 / 3.0 * 100; System.out.printf( “Average of %.3f is failing”, avg); Average of 66.667 is failing
Image of page 104
InputExample.java System.out.println(STORE_NAME); System.out.printf(itemCount + " @ $%.2f %n", pricePerItem); System.out.printf(" Sub-total: %7.2f %n", subtotal); System.out.printf(" Sales tax: %7.2f %n", salesTax); System.out.printf("Total cost: $%7.2f %n", totalCost); Change print statements to show all dollar amounts with rounded to nearest hundredth
Image of page 105
Lab 2
Image of page 106

You've reached the end of your free preview.

Want to read all 106 pages?

  • Spring '16
  • Mr. Mcneal
  • System.out.println, point number, Enter favorite color

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture