Hey, can anyone spot why this thing won't compile. I just don't get it, and it's driving me crazy!!
I get 1 error
59: missing return statement
} // end method toString
^
1 error
I get 1 error
59: missing return statement
} // end method toString
^
1 error
Code:
import java.util.Scanner; // program uses class Scanner
public class Invoice
{
private String customerName; // name of customer this Invoice is issued to
private double invoiceTotal; // total amount of the customer's purchases
// custructor
public Invoice ( String name)
{
customerName = name; // initializes customerName
} // end constructor
// method to retrieve the customer name
public String getCustomerName()
{
return customerName;
} // end method getCustomerName
// method to retrieve the invoice total
public double getInvoiceTotal()
{
return invoiceTotal; // gives the value of invoice total to the calling method
} // end method getinvoiceTotal
// method to obtain user input
public void addItem()
{
// create Scanner to obtain input from command window
Scanner input = new Scanner ( System.in );
// prompt user to unter the unit price and quantity for each item
// prompt user to enter <ctrl> z once all items have been entered
System.out.print("Enter the unit price and quantity purchased or <ctrl> z to quit:");
while ( input.hasNext() )
{
double unitPrice = input.nextDouble();
int quantity = input.nextInt();
invoiceTotal += (unitPrice*quantity);
} //end while
} // end method addItem
public String toString()
{
System.out.printf("Customer Name: %s\n",getCustomerName() );
System.out.printf("Invoice Total: %.2f\n",getInvoiceTotal() );
} // end method toString
} // end class Invoice