Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
public class  LemonadeStand
{
  public static void main(String [] args)
  {
    printTotalSales(int numSales, double price);
  }
  public static double printTotalSales(int numSales, double price);
  {
    double revenue = printTotalSales(17 * 4.45);
    return revenue;
    System.out.println("We sold " + "units at " + "each, which totals ");
  }
}


What I have tried:

I have reread my notes, rewatched the prof's lecture, and still cannot figure out what's wrong with what I'm typing. I've been at it for the past three hours already. The error is at printTotalSales(int numSales, double price); but I don't know what it is.
Posted
Updated 19-Jan-18 17:31pm

1 solution

There are some issue with the code.

1. The main method should call the printTotalSales with the sales and price parameter, see below.
2. The ; after the method declaration , syntax error
3. The println will not get executed
4. Not clear why the code need to call the method printTotalSales recursively. It should be simply sales * price and return the revenue

Java
public class LemonadeStand {
    public static void main(String args[]) {
        System.out.println("Total Sales = " +     printTotalSales(17,4.45));
    }
    
   public static double printTotalSales(int numSales, double price)
    {
        double revenue = numSales * price;
        
        System.out.println("We sold " + numSales +  " units at "+ price + "each, which totals ");
        return revenue;
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900