Search:

Type: Posts; User: jashburn

Search: Search took 0.54 seconds.

  1. Re: Java Program - Distance Traveled (Formatting and Decimal Place)

    As mentioned above, it's just a matter of having


    ...
    long distanceTraveled;
    ...
    System.out.printf("%1d %22d\n", hour, distanceTraveled);

    Everything else remains unchanged. With a long you...
  2. Re: Java Program - Distance Traveled (Formatting and Decimal Place)

    Which approach, (1) 0 precision or (2) long type?

    Note that for an elementary program it is fine to workaround issues by typecasting. Later on you will want to declare your variables exactly what...
  3. Re: Java Program - Distance Traveled (Formatting and Decimal Place)

    There are 2 ways to remove the decimals for issue #2, and they can be done by using just the right formatting in the printf statement.

    1. Specify 0 precision

    "out" in System.out is a...
Results 1 to 3 of 3