Cash Register Program (processing "sales" and "amounts" )

I'm having trouble adding amounts to an array of capacity that the user sets at the beginning of the program. It seems very easy, but I just don't know what to do. It is for a school assignment, so I'm not asking for any freebies. I'd just like to be pointed in the right direction with hints or any useful info. A skeleton was included with the assignment which makes me feel less capable because it's all broken down. Some methods were included. The CashRegister class contains all the methods of the cash register (add amount, remove first occurrence of amount, remove all occurrences, etc.) I'm only lacking the add amount, and both remove occurrence methods.
I think i wrote the add amount method somewhat correctly.. although I'm unsure of how to implement it in case 2 of the switch obviously not as simple as addAmount();
// CashRegister.java
   import java.text.NumberFormat;
   import java.util.Scanner;
    public class CashRegister
      Scanner scan = new Scanner (System.in);
        //instance variables
      private double[] amounts;
      private int numOfValues;
        //constructor
       public CashRegister( int size )
         amounts = new double[ size ];
         numOfValues = 0;
        //increase size of array when needed
       private void increaseSize ()
         double[] temp = new double[amounts.length + 4];
         for (int count=0; count<amounts.length; count++)
            temp[count] = amounts[count];
         amounts = temp;                    
        //add amount to array
       private void addAmount(double newAmt)
         if (numOfValues == amounts.length)
            increaseSize();
         System.out.print ("Enter amount to be added: ");
         newAmt = scan.nextDouble();
         amounts[numOfValues] = newAmt;
         numOfValues++;     
        //toString method
        //returns String representation of CashRegister object
       public String toString()
           //to be used in formating currency values
         NumberFormat fmt = NumberFormat.getCurrencyInstance();
           //initialize resulting String
         String result = "\n";
           //Check if array is empty.
           //If so, print accordingly.
         if( numOfValues == 0 )
            result += "There are 0 register amounts at this time.\n";
         //otherwise, place amounts in result String
         else
         //build result String with amounts
            for( int i = 0; i < amounts.length; i++ )
               result += ( i + 1 ) + ": " + fmt.format( amounts[ i ] ) + "\n";
           //return result String
         return result;
// Project7ADriver.java
   import java.util.Scanner;
    public class Project7ADriver
       public static void main( String[] args )
           //Start Scanner to take input
         Scanner scan = new Scanner( System.in );
           //instantiate a CashRegister
         System.out.print( "How many amounts would you like your register to hold? " );
         int numElements = scan.nextInt();
         CashRegister cr = new CashRegister( numElements );
         int userChoice = 0;
         while( userChoice != 5 )
            menu();
            userChoice = scan.nextInt();
            menuSwitch( userChoice, cr );
       public static void menuSwitch( int choice, CashRegister cashReg )
           //Start Scanner to take input
         Scanner scan = new Scanner( System.in );
         switch( choice )
           //print out amounts
            case 1:
               System.out.print( cashReg.toString() );
               break;
            case 2:
            case 5:
               System.out.println("\nGoodbye!");
               break;
            default:
               System.out.println("Sorry, invalid choice");
       public static void menu()
         System.out.println("\nCash Register");
         System.out.println("*************");
         System.out.println("1: Print the sale amounts");
         System.out.println("2: Add amount");
         System.out.println("3: Remove first occurrence of an amount");
         System.out.println("4: Remove all occurrences of an amount");           
         System.out.println("5: Quit");
         System.out.print("\nEnter your choice: ");
   }

looks like your method signature is wrong
private void addAmount(double newAmt)the method itself gets the amount
newAmt = scan.nextDouble();so its a bit hard passing the amount, when you first call the method
try it like this
      private void addAmount()
         if (numOfValues == amounts.length)
            increaseSize();
         System.out.print ("Enter amount to be added: ");
         double newAmt = scan.nextDouble();
         amounts[numOfValues] = newAmt;
         numOfValues++;     
      }and in your switch
case 2:
  addAmount();
  break;

Similar Messages

  • Need help with a cash register program.

    I'm a noob at JAVA, but having fun with i so far! I was wondering if anyone could help me with a school project I need to get done. I've done most of the work, but I can't get it to not display when I have zero results. What I mean is that the project requires you to create a cash register program that gives you change in 20's, 5's, and 1's for a hundred dollar bill. I get it to display the results, but if there are zero of any category, like in the last problem, I can't let it show. Could someone please help! Thank you in advance! Here's what I have so far (sorry about the rapidshare download ^_^;).
    [http://rapidshare.de/files/39978938/project.java.html]

    Zack,
    The user should not see the line: 0 $5 bill(s)Then you need to detect the situation where no five dollars bills are included in the change, and suppress the output of that line.
    I can read your mind... it's going something like "yeah well righto smartass, I knew that allready... my question was _HOW_ to make that happen...
    And my answer to that is "I'm not telling you"... well, not straight out anyway, coz you'll actually learn more if your struggle a bit (but not too much) yourself...
    So... I suggest you (at least) read through [this page|http://java.sun.com/docs/books/tutorial/java/nutsandbolts/if.html] on the +if+ statement, and maybe even try out the examples, which should (I imagine) take maybe half an hour or so. "Selection" is an absolutely core programming construct... and the concept is common to every programming language ever (AFAIK) invented... meaning that you will really struggle until you "get" the +if+ statement... so that half hour would be time well spent.
    When you've got +if+ concept onboard, you can attempt to apply it to your immediate problem, suppressing those annoying fivers! Have a go yourself, if get really stumped than post a _specific_ question here about the bit that's stumped you.
    I know it can be frustrating... but that just hightens the little thrill you get when you "get it".
    Cheers. Keith.

  • Hello programs on sales and tax returns

    HI ,
    Can any body send sample programs of sales and tax returns of pariticular state .
    i have to use bkpf and bseg tables.
    thanks,
    aravind.

    Hi Radha
    Sales Tax is what u incur on the sales u make as in on Customers - Output Tax -
    Purchase tax is what u incur for ur vendors - Input Tax
    CIN - is specific to Country India Version
    In SAP, we first map a tax procedure to the country specifying whethere there is going to be a Jurisdiction Code or not, then we define input/output taxes in TC FTXP {in FI}; where theSD team will define a condition record mapped to an account key which they will relate to our tax code and they define condition master recd in VK11 for domestic taxes per country.
    Hope this will give u a bried idea on what u wanted to knw
    Rukshana

  • Cash Register

    i am new in J2me programming.
    i wanted to program cash register.
    is it under the j2me cdc programming or under the normal java programming?
    are there any simulater for that cash Register?

    ... and why do you care if i cheat.basically because cheaters are costing the industry millions of dollars they could use else where.
    You will be graduating one of these days, and I will assume that you will want a job. Since you and many more don't have a problem cheating their way through life, the entities that need qualified employees have to rigorously test, interview, and otherwise weed out those that are not able to do the job, but are eminently qualified due to education or experience. When I see a computer science degree on your resume, and major course work in programming, silly me, assumes that you have actually done the work there and can do elementery tasks. I do not have that luxury any longer and test, interview, and weed out candidates accordingly. This more rigorous process costs us 1000's of dollars each year in lost time and resources. I also realize many of the truely qualifed people do not make it to the interview process because they don't test well, don't know how to write a resume as well, or don't make it through the interview process because they don't interview well, but instead of being able to sit down with each applicant and have a relaxed interview, we screen and screen and screen.
    I may add that in the case of entry level jobs and college/hs graduates I get a continuous supply of people that have no more ability to do the job--entry level work--than my cockerspaniel does, because they cheated their way through many of their courses and now cannot deliver using their own skills.
    That is why I care that you cheat.

  • Difference betwen cash sales and rush order

    hai members
    pl mail me the diff bet Cash Sales And Rush Order
    and there implication in Billing documents.
    mail me to: [email protected]

    <b>Rush Order</b>
    In a rush order, the customer picks up the goods immediately, or you deliver them on the same day as when the order was created. When you save the rush order, a delivery is automatically created in the standard system. Billing the rush order takes place as normal, after the delivery.
    In the standard system, sales document type RO is saved for rush orders with immediate delivery type LF. Once the goods have been removed from storage, the goods are picked, and goods issue is posted.
    Once the billing documents are created (for example, in collective processing), invoice papers are printed and sent to the customer.
    IN –IMG-SD-SALES-SALES DOCUMENT HEADER-ORDER TYPE RO/CS U CAN SET A FOR IMMEDIATE DELIVERY IN SHIPPING WHICH CREATES DELIVERY AUTOMATICALLY WHEN U SAVE SALES ORDER
    <b>Cash Sales</b>
    In cash sales, you can process an order for when the customer orders the goods, picks them up, and pays for them immediately. The delivery is processed at the same time as when the order is created and a cash invoice is printed immediately: billing is therefore related to the order, unlike rush and standard orders. Receivables are not created for the customer, as they are for rush and standard orders because the amount in the invoice is immediately posted to a cash account.
    In the standard system, sales document type BV (CS) is saved for cash sales with immediate delivery type BV.
    When the sales employee creates a cash sale, the system automatically proposes the current date as the date for delivery and billing. Once the order has been posted, a delivery with type BV is created immediately in the background and the system prints a document that is used as an invoice for the customer.
    The invoice papers are controlled with output type RD03, contained in the output determination procedure for order type CS.
    Regards,
    Rajesh Banka
    Reward suitable points.
    How to give points: Mark your thread as a question while creating it. In the answers you get, you can assign the points by clicking on the stars to the left. You also get a point yourself for rewarding (one per thread).

  • Cash sale and rush order

    what's the differnce between cash sales and rush order?

    HI
    In case of cash sales the billing document is generated immediately after the order is saved.
    In case of rush order,delivery will be created immediately.
    In a rush order, the customer picks up the goods immediately, or you deliver them on the same day as when the order was created. When you save the rush order, a delivery is automatically created in the standard system. Billing the rush order takes place as normal, after the delivery.
    In the standard system, sales document type RO is saved for rush orders with immediate delivery type LF. Once the goods have been removed from storage, the goods are picked, and goods issue is posted.
    Once the billing documents are created (for example, in collective processing), invoice papers are printed and sent to the customer.
    IN –IMG-SD-SALES-SALES DOCUMENT HEADER-ORDER TYPE RO/CS U CAN SET A FOR IMMEDIATE DELIVERY IN SHIPPING WHICH CREATES DELIVERY AUTOMATICALLY WHEN U SAVE SALES ORDER
    Cash Sales
    In cash sales, you can process an order for when the customer orders the goods, picks them up, and pays for them immediately. The delivery is processed at the same time as when the order is created and a cash invoice is printed immediately: billing is therefore related to the order, unlike rush and standard orders. Receivables are not created for the customer, as they are for rush and standard orders because the amount in the invoice is immediately posted to a cash account.
    In the standard system, sales document type BV (CS) is saved for cash sales with immediate delivery type BV.
    When the sales employee creates a cash sale, the system automatically proposes the current date as the date for delivery and billing. Once the order has been posted, a delivery with type BV is created immediately in the background and the system prints a document that is used as an invoice for the customer.
    The invoice papers are controlled with output type RD03, contained in the output determination procedure for order type CS.
    Differences:
    1.order type is :CS--RO.
    2.Item category: BVN--TAN
    3.no credit active in case of cash sale at item category level.
    4.output type in cash sale:RD00.
    5.account key--EVV(cash sale).
    In cash sales the std sap sales doc type is CS, item category is BVN and Schedule line category is cp. Here when you are creating cash sales order system won't search for credit limits and once cash sales order is created system in background create delivery also .Here we are using a Separate Account key EVV and for output we are using RD03.In cash sales del type is BV, billing type is BV.
    In Rush orders the std sales doc type is RO, item category is TAN, Schedule line category is CP. dely type id LF, billing type is F2,output type RD00 here in rush sales order system in background will create delivery and it will check credit limit of the customer
    Scenario of Cash Sales and Rush Order
    Message was edited by:
            SHESAGIRI.G

  • Cash sales and rush orders.............

    What are the necessary configurations to be done for cash sales and rush orders?

    Hi,
    For Cash Sales the necessary Config Settings are,
    Copy the BV Standard Order and Copy to ZBV and in the functionality of ZBV check whether the field " Immediate Delivery" has the value "X" or not bcoz that creates the Delivery immediately when the cash sale order saved. do the same for item category BVN as ZBVN. and check whether credit active unchecked or not in ZBVN.
      Do the item category determination for cash sale for which u configured. and at the time of cash sale u will get the invoice. for that u use the output type Rd03.
    For Rush Order the necessary Config Settings are,
    Copy the RO Standard Order and Copy to ZRO and in the functionality of ZRO check whether the field " Immediate Delivery" has the value "X" or not bcoz that creates the Delivery immediately when the cash sale order saved. do the same for item category TAN as ZTAN.  Do the item category determination for cash sale for which u configured.and check whether credit active checked or not in ZTAN.
    The Main Difference Between this to are we generally give rush order in credit basis. these two are Fast Sales Process BCOz these two creates immediate Delivery. where as cash sales we will not give the item in a credit basis.
    for RO we generally take the invoice normally i.e normal process.
    Main Difference is
    Order type                    Immediate Delivery                       Credit Active
      OR                                    NO                                          Yes
      BV                                     Yes                                         NO
      RO                                     Yes                                         Yes
    These are the necessary Configurations,
    Reward If Helpful,
    Regards,
    Praveen Kumar.D

  • Sync phone to computer and the process a significant amount of my contact list.  All "A"s, all but 2 B's, all but 4 c's then left everything else as is.  What's that all about and can I retrieve what was lost?

    sync iphone to computer and in the process a significant amount of my contact list was deleted.   All "A"s, all but 2 B's, all but 4 c's then left everything else as is.  What's that all about and can I retrieve what was lost?

    iTunes Store- Transferring purchases from iOS device or iPod to a computer
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    How to dowload purchased music

  • Process blocked sales and distribution documents from the SAPoffice inbox

    Hi,
    I know VKM1/VKM3 can be used to release order.
    And SAP help shows we can process blocked sales and distribution documents from the SAPoffice inbox. Could anyone tell me how?
    I can use output type KRML to send a mail to SAPoffice inbox, but don't know how to release blocked sales orders in the SAPoffice inbox.
    Many Thanks
    Jean

    Hello Jean,
    Release the blocked document directly via mail received:
    - After carry out the step  4 in note 677377, you will be able to
      release the blocked document directly by:
      Display the SAP office mail recieved;
      Menu: Document -> Execute;
      Then you will be redirected to transaction vkm3, with the blocked
      document number defaulted on that screen;
    Unfortunately, it is not possible to direct your mails to Outlook
    and release the document from VKM3.
    Best regards,
    Lela

  • Intercompany sales and sales process exc Duty for Netherlands and Belgium

    Can anyone explain me the sales and intercompany sales process where materials are excise Duty relevant for Netherlands and Belgium ? That means sales is done via the Netherlands for Netherlands and Belgium ? How are the different tax rates configured for the different countries ?

    HI Garima ,
    Plz check the following steps
    CONFIGURATION SETTINGS
    Assign Delivery Plant of the supplying company code to Sales Org + Distribution channel of the Ordering company code in the Enterprise Structure.
    DEFINE ORDER TYPES FOR INTERCOMPNY BILLING:
    Menu path: IMG/ SD/Billing/Intercompany Billing/Define Order Types for Intercompany billing
    Assign Organizational units by Plant:
    Menu Path: IMG/ SD/Billing/Intercompany Billing/Assign Organizational units by Plant.
    Define Internal Customer Number By Sales Organization:
    Menu Path: IMG/ SD / Billing/ Intercompany Billing/ Define Internal Customer Number By Sales Organization:
    Creating / Showing Ordering Sales Organization as Internal Customer for Supplying Company code:
    Transaction Code: XD01
    The ordering sales organization is represented as Internal customer of Supplying company code.
    We need to create customer master in Account Group - Sold to Party and maintain minimum required financial & Sales Area data.
    This internal customer number has to be assigned to the ordering sales organization. Hence, the system automatically picks up this Internal customer number whenever there is Intercompany billing.
    In the  above mention configuration steps you are missing  the second step in your confirguration 1.e the reason  your  getting that error
    Best regards
    Venkat

  • Difference between business process, sales process and order process

    what is the difference between business process, sales process and order process?

    Dear Gopala,
    business process is a general definition of the process which you have:
    for example, you get an order, you have no goods, but you can produce them, you start an assambly processing, the production order will be created, then the goods will be prepatred, then the delivery will be created, the goods issue booked then your customer gets thwe goods and send the delivery confirmation, you create an invoice etc.etc.
    sales process is a part of  a business process.
    Sales process shows how you sell the goods, there are different sales document  categories to do this: sales orders, contracts, scheduling agreements etc.
    order process is only one of possibilities of the sales process.
    Order process is used if you get really a one-time (or at lease not on a regular basis many times) the simple orders where your customer says what goods he would like to receive and when. Then you create a sales order (in dialog transaction VA01) and can create a delivery. There are different types of sales orders in the standard. The customizing of sales order types is available under the transaction VOV8.
    I hope, this info help you a little bit further to understand SD design.
    Kind regards,
    Akmal Vakhidov
    Development Support SD, SAP

  • Can I include a ClickOnce deployment and rest Registry ActiveX dll to register (program created by c #)?

    hi !
    Can I include a ClickOnce deployment and rest Registry ActiveX dll to register (program created by c #)?
    Please answer.

    hi !
    Can I include a ClickOnce deployment and rest Registry ActiveX dll to register (program created by c #)?
    Please answer.
    Hello,
    We could not registry activex dll with clickonce directly, but here is a workaround below.
    1. Create Package for that activex dll to registry it to com.
    2. Package that MSI to CAB file.
    #1,#2 for detailed steps, please refer to the following blog.
    How to develop and deploy ActiveX control in C#
    3.
    Deploying CAB Files Using ClickOnce Deployment
    Regards,
    Carl
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Bussiness process of Inter company sales and why we suggest Inter company

    Dear All SD Gurus,
    I want to Know the business procees of inter company sales and why we suggest inter company sales to clint?.
    Because in Third party sales also vendor delivers the goods to customer so why we need to go for Inter company.I want know the Major defferences between them.
    Please Help
    Regards
    S Kumar

    Dear Sandeep
    1)  Inter Company Transfer
    We should not call the inter company transfer as sales.  The proper way to account for these transfers is to treat them as consignment sales.
    Why?
    1)  You do not recognize income until the stock is actually sold to the end user (ie retailer, wholesaler).
    2)  You minizime your taxable income.
    2)  Third Party Sales
    In third-party order processing, your company does not deliver the items requested by a customer. Instead, you pass the order along to a third-party vendor who then ships the goods directly to the customer and bills you. A sales order may consist partly or wholly of third-party items. Occasionally, you may need to let a vendor deliver items you would normally deliver yourself.
    Thanks
    G. Lakshmipathi

  • How to register PROGRAM ID and use it in SM59, then see it in SMGW

    Hi guys,
    I want to build a RFC connection, it has 2 sides, first in SAP and 2nd in .Net .
    In SAP side as far as I know I have to create a RFC Destination in SM59 with Type T (TCP/IP Connection).
    It wants a Program ID in Technical settings when you choose "registered server program".
    I read a lot forums but still I have problem that "what is a registered program and how can I create it".
    Thanks guys

    Dear Farzin
    To build such a connection, you need to follow the below steps in order:-
    i) External system (.NET) registers program in gateway
    ii) View in SMGW that the program is registered
    iii) Create in SM59 new RFC type T
    You can also refer to my answer in the following thread:
    RFC Destination TCP/IP - IDoc to Third Party in ECC
    I am not familiar with .NET programming, so not sure what needs to be done on that side for step i, but you should be able to search for more details. One of my search result points to the following which might be suitable:-
    Build an RFC Server with NCo 3.0 – A Step-By-Step Guide | SAP Experts:Consulting &amp;amp; Integration - DataXstream
    Once you complete all the steps, you can test the new RFC connection in SM59 to see if it works before you try out the function module.
    Rgds
    Eng Swee

  • APP-AR-12022: A cash receipt with this number,date,amount and customer alre

    Hi,
    There is a caution(Warning message) of Duplicate receipt entery in Oracle AR Receipts entry window which pops up while creating the receipts.
    APP-AR-12022: A cash receipt with this number,date,amount and customer already exists.
    Normally it comes when we enter similar receipt number, net receipt amount and receipt date towice.
    Is it possible to customize the criteria for this caution.
    Thanks.

    You cannot customise this. If you want additional validation at the time of entry/update from forms, you can code special logic in custom pll. But you cannot change the standard functionality.

Maybe you are looking for