I'm making a self checkout machine where the user inputs prices and it comes out with a total. I'm supposed to show them this total after they enter a new value, so if they enter 20, then total price is 20 and if they enter another 20 its 40 and so on.
My problem is, my code only shows how much they entered and not the total.
Code:
/*
Program: Ahmed_Mohamed_Project2.java
Author: A. Mohamed
Date: Nov, 23/2012
Description: A program that simulates a self checkout machine
*/
import java.util.Scanner;
public class fff
{
public static void main(String[] args)
{
double runningtot;
Scanner input = new Scanner (System.in);
double[]runningArray = new double[14];
System.out.println("Big Box Depot Self-Serve Checkout");
System.out.println("");
System.out.println("Hi. Welcome to the checkout. What's your name? ");
System.out.println("");
String name = input.nextLine();
System.out.println("");
System.out.println("Okay, " + name + ", enter the price of each purchase in dollars and cents, and then push the ENTER key. For example, if item costs $5.99 enter 5.99");
System.out.println("");
System.out.println("If you make a mistake when you enter a price enter a zero for the next entry and the last price you entered will be subtracted from your running total.");
System.out.println("");
System.out.println("When you've entered all of your prices, enter -1 to indicate that you've finished your entries. I’ll then calculate what your total owing is.");
System.out.println("");
for(int count = 0; count < runningArray.length; count++)
{
System.out.println("Please enter price of item: ");
double price = input.nextDouble();
System.out.println("");
System.out.println("That was $" + price);
System.out.println("");
runningtot = price;
System.out.println("Your total price is $" + runningtot);
}
}
}
IMAGE ATTACHED