Output is nearly correct; but whitespace differs. See highlights below. Special character legend Input 20. 1599 Your output 1. 58 7. 90 63.20...
View the step-by-step solution to:

Question

Hello,


I am having some issues removing whitespace. The this is the answer they are looking for

compared to my current output.


Screen Shot 2019-11-06 at 1.49.58 PM.png


import java.util.Scanner;


public class LabProgram {


  public static double drivingCost(double drivenMiles, double milesPerGallon, double dollarsPerGallon) {

     double dollarsNeeded = 0;


     dollarsNeeded = (drivenMiles / milesPerGallon) * dollarsPerGallon;

     return dollarsNeeded;

  }


  public static void main(String[] args) {

     double milesGallon = 0;

     double dollarGallon = 0;


     milesGallon = scnr.nextDouble();

     dollarGallon = scnr.nextDouble();


     System.out.printf("%.2f ", drivingCost(10.00, milesGallon, dollarGallon));

     System.out.printf("%.2f ", drivingCost(50.00, milesGallon, dollarGallon));

     System.out.printf("%.2f ", drivingCost(400.00, milesGallon, dollarGallon));

  }

  public final static Scanner scnr = new Scanner(System.in);


}

Screen Shot 2019-11-06 at 1.49.58 PM.png

Output is nearly correct; but whitespace differs. See highlights below. Special character legend
Input
20.0 3. 1599
Your output
1. 58 7. 90 63.20
Expected output
1 . 58 7. 90 63.20+

Top Answer

I have altered few changes.... View the full answer

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question