Results 1 to 5 of 5
  1. #1
    glockner is offline Member
    Join Date
    Jan 2015
    Posts
    31
    Rep Power
    0

    Default Daily Sales trouble...

    How do you delete posts from this website?
    Last edited by glockner; 01-27-2015 at 10:09 PM.

  2. #2
    glockner is offline Member
    Join Date
    Jan 2015
    Posts
    31
    Rep Power
    0

    Default Re: Daily Sales trouble...

    Figured out my problem... needed have dailySales += currentAmount.

  3. #3
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    14

    Default Re: Daily Sales trouble...

    Quote Originally Posted by glockner View Post
    Figured out my problem... needed have dailySales += currentAmount.
    What you should have done was leave your original post and then simply post the solution.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    26

    Default Re: Daily Sales trouble...

    Quote Originally Posted by glockner View Post
    How do you delete posts from this website?
    For the record, this was the post:
    Quote Originally Posted by glockner View Post
    -
    I am creating a cash register. I need it to keep track of daily sales along with other components. Referring to line 135 in particular, I am trying to add the total amount of that purchase into the overall daily sales. When I go to run the method to get daily sales it shows up as $0.00 no matter what prices I put in to the payment. Any suggestions on how to store the prices of final payments into the daily sales? Thanks.

    Java Code:
     import java.util.*;
     import java.text.*;
    
     /************************************************** *****************************
     * Create a simple class for a cash register.
     * 
     * @author George Glessner
     * @version January 26, 2015
     ************************************************** *****************************/
     public class cashRegister{
    
     /** current amount due */
     private double currentAmount;
    
     /** daily sales */
     private double dailySales;
    
     /** number of customers */
     private int customers;
    
     /** store name */
     private String storeName;
    
     /** sales tax */
     private final double TAX = 0.06;
    
     /** calculate sales tax */
     private double salesTax;
    
     /** number format */
     NumberFormat fmt = NumberFormat.getInstance();
    
     /************************************************** *************************
     Constructor for objects of class Register
     ************************************************** **************************/
     public cashRegister(){
     //Define variables
     currentAmount = 0.00;
     dailySales = 0.00;
     customers = 0;
     storeName = "George's Corner Store!";
     salesTax = 0.06;
    
     }
    
    
     /************************************************** ************************
     Constructor for objects of class Register
     Alternative constructor
    
     @param pName name of store
     ************************************************** *************************/
     public cashRegister(String pName){
     //Define Variables
     currentAmount = 0.00;
     dailySales = 0.00;
     customers = 0;
     storeName = pName;
     salesTax = 0.06;
    
     }
    
     /************************************************** *************************
     Scan an item's price
    
     @param price total price of object
     ************************************************** **************************/
     public void scanPrice(double price){
     //Set up formula for current amount and apply number format
     NumberFormat fmt = NumberFormat.getCurrencyInstance(); 
     currentAmount += price;
     System.out.println("Price: " + fmt.format(price));
    
     }
    
     /************************************************** *************************
     Get current amount due
    
     @return current amount due
     ************************************************** **************************/
     public double getPrice(){
     return currentAmount;
     }
    
     /************************************************** *************************
     Get daily sales
    
     @return current amount due
     ************************************************** **************************/
     public double getDailySales(){
     return dailySales;
     }
    
     /************************************************** *************************
     Get number of customers
    
     @return number of customers
     ************************************************** **************************/
     public double getCustomers(){
     return customers;
     }
    
     /************************************************** *************************
     Tally Purchases
    
     @param purchases amount of purchase after sales tax included
     ************************************************** **************************/
     public void tallyPurchases(){
     //Gets total amount of purchases including sales tax and applies number format
     NumberFormat fmt = NumberFormat.getCurrencyInstance();
     salesTax = (currentAmount * TAX);
     currentAmount = salesTax + currentAmount;
     System.out.println("Sales tax: " + fmt.format(salesTax));
     System.out.println("Amount Due: " + fmt.format(currentAmount));
    
    
     }
    
     /************************************************** *************************
     Cancel Purchase
    
     @param cancel all purchases
     ************************************************** **************************/
     public void cancelPurchases(){ 
     NumberFormat fmt = NumberFormat.getCurrencyInstance();
     currentAmount = 0.00;
     System.out.println("Purchase cancelled.");
    
     }
    
     /************************************************** *************************
     Make a payment
     ************************************************** **************************/
     public void makePayment(){
     currentAmount += dailySales;
     customers = (customers + 1);
     currentAmount = 0.00;
     System.out.println("Thank you. Have a nice day!");
    
     }
    
     /************************************************** *************************
     Reset register
     ************************************************** **************************/
     public void resetRegister(){
     dailySales = 0.00;
     currentAmount = 0.00;
     customers = 0;
    
     }
    
     /************************************************** *************************
     Cash register test. Tests all inputs/outputs
     ************************************************** **************************/
     public static void main (String args []){
     cashRegister gMart = new cashRegister("George's Mart");
     System.out.println("Welcome to " + gMart + "!");
     gMart.scanPrice(10);
     gMart.scanPrice(20);
     gMart.getPrice();
     gMart.tallyPurchases();
     gMart.makePayment();
     gMart.getCustomers();
     System.out.println("");
    
     cashRegister uMart = new cashRegister("Your Mart");
     System.out.println("Welcome to " + uMart + "!");
     uMart.scanPrice(10);
     uMart.scanPrice(20);
     uMart.getPrice();
     uMart.cancelPurchases();
     uMart.scanPrice(95.64);
     uMart.tallyPurchases();
     uMart.makePayment();
     uMart.getCustomers();
     uMart.getDailySales();
     System.out.println("");
     }
    
     }
    THREAD CLOSED

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,716
    Rep Power
    18

    Default Re: Daily Sales trouble...

    %%%%%

    Closed? Whatever.

    @OP. The culture is don't delete threads: they belong to posterity!

    I don't know how many times a solution to a problem I had came from an old post that I happened upon. That's what ultimately made me start contributing to Java forums. Don't worry about importance - google is very, very good at determining importance. Moderators will go to the trouble of deleting posts where sensitive information was posted by accident, but for the rest just let it go. Think how much future archeologists will learn from teh Internet's forums. And shudder.
    Last edited by pbrockway2; 01-28-2015 at 04:26 AM.

Similar Threads

  1. Re: Help doing GUI in sales and inventory
    By cuddles14 in forum Eclipse
    Replies: 0
    Last Post: 03-08-2011, 12:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •