I am trying to build a very quick invoice type program, and I can't seem to get the final total to print. I am calling the function for it, but it's not printing anything to the screen...any suggestions?
public class Invoice
{
private double Total;
//Constructor
public Invoice( double initialBalance )
{
// validate that initialBalance is greater than 0.0;
// if it is not, balance is initialized to the default value 0.0
if ( initialBalance >= 0.00 )
Total = initialBalance;
} // end Account constructor
// Find amount
public void price(double Price, double NumberOfItem )
{
Total = Total + (NumberOfItem * Price); // add amount to balance
} // end method credit
// return the account balance
public double getTotal()
{
return Total; // gives the value of balance to the calling method
} // end method getBalance
} // end class Account
and an invoice testing program:
public class InvoiceTest
{
// main method begins execution of Java application
public static void main( String[] args )
{
Invoice account1 = new Invoice(0.00); // create Invoice object
// display initial balance
System.out.printf( "Current Account Balance is: $%.2f\n",
account1.getTotal() );
// create Scanner to obtain input from command window
Scanner input = new Scanner( System.in );
double Price; //Price of each item
int NumberOfItem; // Number of Item Being Purchased
String Tool; //name of tool read from user
String Description; //description of item
//Intake Name of Item From customer
System.out.println("Enter Name of Item: ");
Tool = input.nextLine();
//Intake Description of Item From Customer
System.out.println("Enter Description of Item: ");
Description = input.nextLine();
//Enter Number of Items Being Purchased
System.out.println( "Enter number of " + Tool + "(s)" + " being purchased:" );
NumberOfItem = input.nextInt();
//Enter Price For Each Tool
System.out.println( "Enter Price For Each " + Tool + " :" );
Price = input.nextDouble();
//Find Final Price For Invoice
System.out.printf("Total of Purchase is:", account1.getTotal());
} // end main
}
This is the output that I'm getting:
Current Account Balance is: $0.00
Enter Name of Item:
asdf
Enter Description of Item:
asdf
Enter number of asdf(s) being purchased:
10
Enter Price For Each asdf :
5
Total of Purchase is: