Objects, Overloading, and Stock Prices

The problem - Write a program that has the following:
Data:
A string field named symbol for the Stock’s symbol.
A a string named sName for the Stock’s name.
A double field named previousClosingPrice that stores the stock’s prices form the previous day.
A double data field named currentPrice that stores the stock price for the current time.
Behaviors: (i.e. methods)
A default Constructor.
An overloaded Constructor that takes a stock with a specific symbol, name, and last closing price. ** Note values for current stock price will have to be initialized to zero.
A toString(); function that returns the current stock’s name, Symbol, and current price.
A method named getChangePercent(); that returns the percentage changed between previousClosingPrice and currentPrice.
A method named setCurrentPrice(double); that allows the setting of the current stock price.
Write a test program that creates a Stock object with the symbol ORCL, the name Oracle Corporation, and the previous closing price of 34.5.
Also, have the test program call the toString(); method to see it’s definition.
Lastly, set the new stock price to 34.35 and then display the price change percentage.
My problem is the math aspect to calculate the percentage. My result is "Infinity", which is obviously wrong. What am I missing here?
package stockPrice;
public class Stock {
//Set Data fields
     public String symbol;
     public String sName;
     public double previousClosingPrice;
     public double currentPrice = 0;
//Default Constructor
     public Stock(){
//Constructor with previous closing price parameter
     public Stock(String newSymbol, String newSName, double newPreviousClosingPrice) {
          this.symbol = newSymbol;
          this.sName = newSName;
          this.currentPrice = newPreviousClosingPrice;
//Return Percent Change
     double getChangePercent(){
          return (((previousClosingPrice - this.currentPrice)/previousClosingPrice)*100);
//Set a new Current Price
     double setCurrentPrice(double newCurrentPrice){
          this.currentPrice = newCurrentPrice;
          return this.currentPrice;
     @Override
     public String toString() {
          // TODO Auto-generated method stub
          String total = "The symbol is: " + this.symbol + " and the name is: " + this.sName + " and the previous closing price is: " + this.currentPrice;
          return total;
}Driver:
package stockPrice;
public class Driver{
     public static void main(String[] args) {
     //Driver Program for all testing and Instantiation     
          Stock stock1 = new Stock ("ORCL", "Oracle Corporation", 34.5);
          System.out.println(stock1.toString());
          stock1.setCurrentPrice(34.35);
          System.out.println(stock1.toString() + ". The percent change is: " + stock1.getChangePercent());
}

So is setting the price as simple as this? (Keeping in mind this is my first JAVA class I am taking)...
package stockPrice;
public class Stock {
//Set Data fields
     public String symbol;
     public String sName;
     public double previousClosingPrice = 34.5;
     public double currentPrice = 0;
//Default Constructor
     public Stock(){
//Constructor with previous closing price parameter
     public Stock(String newSymbol, String newSName, double newPreviousClosingPrice) {
          this.symbol = newSymbol;
          this.sName = newSName;
          this.currentPrice = newPreviousClosingPrice;
//Return Percent Change
     double getChangePercent(){
          return (((previousClosingPrice - this.currentPrice)/previousClosingPrice)*100);
//Set a new Current Price
     double setCurrentPrice(double newCurrentPrice){
          this.currentPrice = newCurrentPrice;
          return this.currentPrice;
     @Override
     public String toString() {
          // TODO Auto-generated method stub
          String total = "The symbol is: " + this.symbol + " and the name is: " + this.sName + " and the previous closing price is: " + this.currentPrice;
          return total;
}

Similar Messages

  • What is the difference between WTR1 stock price and Price,some time both are zero?

    what is the difference between WTR1 stock price and Price,some time both are zero?
    please advice

    Hi,
    Are you referring these two field in WTR1 table? If yes,
    (Figure 1 There is no price defined and received with zero price)
    1. Based on price list, this info price will be updated. If there is no price, this field is zero
    2. If you receive any item without price (for GRPO with zero price), then field is zero
    3. If you receive item with price, based on quantity, the moving average price will be updates at item cost.
    Thanks & Regards,
    Nagarajan

  • MB5L Report Discrepacy for Material and Stock Account Currency

    I have found in the MB Report Discrepancy for Material and Stock Account Currency. Why is this happening? Why is there a variance between total price in materials and stock account? Anyone please help me. I'm abaper but now been pushed to do logistic. I need help for this issue.

    Hi,
    Here's some information from help. Variances can occur for the following reasons:
    You have entered postings to the stock account manually.
    The stock account includes not only stock postings, but also other postings. In this case, you should check the account determination in the Customizing for Valuation and Account Assignment. Make sure that the stock accounts are used solely for the transaction key BSX (stock postings).
    Check Account Determination - OMWB
    The account assignment for the stock accounts (transaction key BSX) was changed during productive operation; the respective stocks, however, were not deducted from the old account (movement type 562) and posted to the new one (movement type 561).
    Cheers !

  • Custom Report for the Stock and Stock value for a specific date

    Hi SAP Gurus,
    Is there any SAP standard t-code or any logic to get the transcations (additions (for example: Purchases) and subtractions (Sales) to the inventory) for a particular materials in a plant and with Total Stock and also Total Stock value when that particular transaction happened?
    Our system is R/3 4.7
    I looked at the MB5B, MBCE, MBCA, MC44, MB51 and some other standard T-codes but could not find the total stock value at the time of Transaction happened.
    The history tables MBEWH and MARDH  are updated after the month end closing procedures, right, which means I will have the inventory value changing every month if material has Price "S".
    Thank you,
    -Harter

    Hi Harter,
    Unfortunately, you cannot see in a single tcode the value of stock and stock quantity on a specific date. As you yourself have pointed out, we only have to make use of the history table MBEWH, MARDH for the month wise stock quantity and value. Along with that you should also make use of the table MBEW to take teh stock quantity and value. So the total value of stock on a particular date will be
    Stock qnty = MBEWH value until the previous month (for teh specific valuation class, period etc) + MBEW value for the present date.
    But this will nto work out if you want to find out teh stock quantity and stock value on a past date basis. For past data, only  m onthwise data is available. For this anyway you can refer to MC.1 and so on reports.

  • Check Credit and Stock on Sale Order

    Hi All
    Could you please tell me how to check Credit and Stock on Sale Order.
    Thank and Best Regard
    Thang

    How To Do Configuration For Credit Management
    Credit and risk management takes place in the credit control area. According to your corporate requirements, you can implement credit management that is centralized, decentralized, or somewhere in between. 
    An organizational unit that represents the area where customer credit is awarded and monitored.   This organizational unit can either be a single or several company codes, if credit control is performed across several company codes. One credit control area contains credit control information for each customer.
    For example, if your credit management is centralized, you can define one credit control area for all of your company codes. 
    If, on the other hand, your credit policy requires decentralized credit management, you can define credit control areas for each company code or each group of company codes. 
    Credit limits and credit exposure are managed at both credit control area and customer level.  You set up credit control areas and other data related to credit management in Customizing for Financial Accounting. The implementation guide is under Enterprise Structure -> Definition or Assignment -> Financial Accounting and then Maintain credit control area. You assign customers to specific credit control areas and specify the appropriate credit limits in the customer master record.
    Settings for determining the credit control area of a document.  The settings of items 1 - 4 are taken into account according to their priority.  The credit control area found is stored in field VBAK-KKBER.
    1. Transaction OB38
       Check which credit control area is assigned to the company code.
       Company code:
       Credit control area:
    2. Transaction OVFL
       Check which credit control area is assigned to the sales area.
       Sales area:
       Credit control area:
    3. Transaction XD02 or VD02
       Check which credit control area is assigned to the payer.
       Payer:
       Credit control area:
    4. Transaction SE37
       Is user exit EXIT_SAPV45K_001 being used?
    5. Transaction OBZK
       For the settings under items 2 - 4, field "All company codes" must be marked in Transaction
       OB45, or the credit control area must be entered under the relevant company code in table
       T001CM of the credit control areas allowed.
       Company code:
       Credit control areas allowed:
    6. Settings for the credit checks
    7. Transaction OVAK
       Which settings do exist for the sales document type used?
       Sales document:
       Check credit:
       Credit group:
    8. Transaction OVAD
       Which settings do exist for the delivery type used?
       Delivery type:
       Credit group for delivery:
       Credit group for goods issue:
    9. Transaction OB01
       Credit management/Change risk category
       Definition of the risk category for each credit control area. This risk category can be
       assigned to a credit account by using Transaction FD32.
    10. Transaction OVA8
        Here, the individual credit checks for key fields
        o credit control area
        o risk category
        o credit group are set. Take these key fields from the above settings and go to the detail
          screen. In particular, check whether fields "Reaction" and "Status/block" are set
          correctly. To carry out follow-up actions in case of a credit block, the credit check
          status must be set (field "Status/block").
    11. Transaction FD32
        Credit master data for the payer of the relevant document.
        Credit account:
        Credit limit:
        Risk category:
        Currency:
    12. Settings for updating the credit values Update of the credit values is required for the limit
        check (static or dynamic credit limit check).
    13. Transaction OVA7
        Update of the credit value is active for the corresponding item type if the check box is marked. This field corresponds to 
        field "Active receivable" in Transaction VOV7.
        Item type: 
        Active receivable:
    14. Transaction V/08, Pricing
        In the pricing procedure used for pricing, subtotal "A" must be entered in a line for
        determining the credit value (mark the pricing procedure and doubleclick on "Control").
        Usually, the net value plus taxes is used. This way the system is determined to use this
        subtotal for credit pricing. The credit price is stored in field VBAP-CMPRE and used for
        update and credit check.
        You can find the used pricing procedure of the order under "Item -> Condition -> Analysis".
        Pricing procedure:
        Line with subtotal = 'A':
    15. Transaction OB45
        Which update group (field "Update") do you use in the relevant credit control area? The
        default setting is "12". If you use another update group, check whether this is fine with
        you. If you open an OSS message, please tell us the alternative update group.
        Credit control area:
        Update:
    16. Transaction OMO1
        Which kind of update did you choose for structure S066? 
         In any case, "Synchronous update (1)" has to be chosen as the kind of update. 
         All other settings will lead to errors
    Regards
    Raja
    Edited by: ramanathan raja on Jul 25, 2008 4:37 PM

  • Make to order and stock both in one material with consignment

    Hi Seniors
    FERT Material = XYZ which is being used for Make to Order and Make to stock both.
    In case of make to stock  scenario from GR u2013 101 and PGI made @ std price. At the time of Consignment 631 mvt. No accounting document is generated. As per my knowledge its fine. No issue.
    In case of Make to order scenario for above material.
    Q.1   At the time of goods receipt (101 Mvt) from production order,  accounting document is generated at the rate of Per unit target cost of production order and no variance shown on production order. Why not accounting document is created at Std price of Material?
    Q.2 At the the time of consignment an accounting document generated with following entry.
        Finished Goods Inventory      Dr
        Price difference                   Dr             
                        Finish Goods Inventory Cr
    Why accounting document is generated at the time of consignment in case of make to order scenario?  Pls confirm is this a sap standard behavour or anything wrong with me. As I told earlier that in case of make to stock when we make 631 mvt there is no accounting document generated.
    Note: My standard price is on the base of mix costing using two production versions.  Every time we create production order in each version.
    Regards
    Imdad

    Hi Imdad
    Q1: Why not accounting document is created at Std price of Material?
    Check your req class... There is a Field called "Valuation"... your valuation depends on whether you select M or A there... You can decide to valuate based on CK11N std cost estimate or based on Sales order cost estimate / Prod order cost estimate
    So, in a nut shell, you can configure the system to generate acc doc at CK11N Std cost also
    Q2. Why accounting document is generated at the time of consignment in case of make to order scenario?
    In my opinion, your MTO stock is maintained in Table EBEW.. Pls check that... WHen you do GR from Prod order, it resides in EBEW table..
    However, when you send it as a cons stock, the link to sales order is lost and your stock is no longer a MTO stock.. Hence, it is valuated at CK11N Std Cost.... If there is a diff between CK11N cost and GR Price, then PRD is generated... Thats why you are seeing PRD in your case
    BR, Ajay M

  • I am in need of a weather and stock widget, similiar to the ones on the iphone 4s, that allow you to display current stocks and weather in the notification window but i need it for the ipad2.

    the iphone 4s came with a weather and a stock widget.  these could be configured in notifications to CONSTANTLY display stock prices and the days weather whenever you pulled down the notification window.  the ipad2 doesn't have these programs and i have spend a small fortune and time looking for this same feature.  does anyone out there know off a weather and stock program that will let you program stocks into the notification window and then stream the stocks and prices acrossthe screen continously when you open the notification window.  Also does anyone know of a weather program that will display the days current conditions ALL THE TIME, not just when the wind picks up or it snows.
    the ipad2 doesn't have these built in programs and i can't find similiar ones in the app store.
    Thanks for your help.
    [email protected]

    I have this question too. Have you had any replies?

  • Procurement cycle in third party order and stock transport order.

    please provide me in steps the procurement cycle in third party order and stock transport order.

    Hi,
    STO Process: -
    1.Create a vendor for the company code of receiving plant, using account group :0007 using T-Code XK01.
    2. Assign this vendor to Delivering plant
    Go to XK02 >Purchasing view>Extras>Add. Purchasing data>Plant
    3. Create internal customer with the sales area of the vendor. Go To XD01
    4. In Pricing procedure determination relevant to STO, assign document Pricing Procedure and customer pricing procedure appropriate for STO to get the pricing in the invoice.
    5. Maintain condition records for the relevant pricing condition.
    6. Some more setting for STO: Go to MM> Purchasing > Purchase Order > Set up STO > define shipping data for plants > Go to Receiving plant >assign customer here & Supplying SA (for billing) to Receiving plant here
    7. Go to MM > Purchasing > Purchase Order > Set up STO > define shipping data for plants > Go to Supplying plant and assign the sales area of receiving plant.
    8. Go to MM > Purchasing > Purchase Order > Set up STO > assign delivery Type & Checking rule
    Assign the delivery type to document type. In this case, Delivery type NLCC is assigned to Document type NB
    9. Go to MM> Purchasing > Purchase Order > Set up STO > Assign document Type, One step Procedure, Under delivery tolerance
    Assign the document type NB to supplying plant and receiving plant
    10. After all settings , Create the STO using T-Code:ME21N and maintain pricing conditions of freight and Save.
    11. Create Delivery :VL10G
    Click on the Background Button after selecting line item
    A message is flashed : See log for information> next Click on Log for delivery creation Button >click on line item>click on document button to get Delivery document No
    12. Picking, PGI:VL02N
    13. Billing:VF01
    Save the document and its done
    14. J1IIN - Outgoing Excise Invoice
    15. MIGO - Goods Receipt against outbound Delivery
    16. J1IEX - Capture & Post Excise Invoice
    Pricing configuration for STO: -
    In SPRO > MM > Purchasing > Conditions > Define Price Determination Process > Define Schema Determination > Determine Schema for Stock Transport Orders > Here assign Calculation Schema "RM2000" i.e. Stock Transfer Document to Schema Grp Pur. Org, STO Type (For e.g. UB) and Supplying Plant.
    Calculation Schema "RM2000" has condition type P101 which will pick up the MAP of supplying plant automatically during creation of STO in ME21N ("Conditions" Tab).
    You can create new freight / delivery cost conditions in M/06 and assign in pricing procedure "RM2000" in M/08 and also assign the Accrual Key to this and do the Account Determination for this Accrual Key in OBYC
    At the time of PGI, following accounting entry will get generated;
    Stock A/c - Dr - 110 INR (Receiving Plant)
    Stock A/c - Cr - 100 INR (Supplying Plant)
    Freight Clearing A/c - Cr - 10 INR (Supplying Plant)
    Third Party Process Flow: -
    1) MM01 - General Item category Group should be BANS in basic view of material master.
    2) VA01 - Creation of sales order with VA01 transaction in SD module
    3) When sales order is created system automatically creates a PR for the material with item category as "S"--> Third Party Item
    4) ME21N - Directly PO with item category as "S" and delivery address as customer address
    5) MIGO - Statistical GR by MM ( When it is made goods are received and delivered)
    6) MIRO - Invoice by MM for vendor
    7) VF01 - Billing by SD on Customers

  • What's the difference between "overloading" and "overriding" in Java

    What's the difference between "overloading" and "overriding" in Java

    hashdata wrote:
    What is the real-time usage of these concepts...?Overriding is used when two classes react differently to the same method call. A good example is toString(). For Object it just returns the class name and the identityHashCode, for String it returns the String itself and for a List it (usually) returns a String representation of the content of the list.
    Overloading is used when similar functionality is provided for different arguments. A good example is [Arrays.sort()|http://java.sun.com/javase/6/docs/api/java/util/Arrays.html#sort(byte%5B%5D)]: all the sort() methods do the same thing (they sort arrays), but one sorts byte-arrays, another one sorts int-arrays, yet another one sorts Object-arrays.
    By the way, you almost certainly mean "real-world" usage. "real-time" (and thus "real-time usage) means something entirely unrelated to your question.

  • G/L Account Determination - Variance - Expense and Stock Account

    Hi All,
    Under G/L Account Determination -> Purchasing tab -> General tab the last account is called "Expense and Stock Account", in some versions the same is called "Variance Account - Expense and Stock Account". In the help file and on the SAP Portal it is explained to be used as:
    "Define a variance G/L account for clearing journal entries created by A/P credit memos that were based on A/P invoices or created by goods return that were based on goods receipt POs, in which the freight charges or the price were changed."
    I'm trying to test this but recreating the scenarios described above the account will not be used. Can anyone help me what am I missing?
    Thanks and regards,
    Nat

    Hi ShriX,
    I understand but my problem is when I'm testing these scenarios, in my test system the account is not used at all. For example I have an AP Invoice and when I turn it to an AP Credit Memo I change the price of the item. I would expect a posting to this account as it is specified in the help file, but in my case it doesn't happen. Do you know why?
    Thanks and regards,
    Nat

  • How to activate Image, Pdf, Hyperlink and Scale Prices in SRM-MDM

    Hi Experts,
    I have requirement to activate the following features:
    1. Image
    2. PDF
    3. Hyperlink
    4. Scale Prices
    These should be activated and should be available in the current business' internal catalogs so that users could be able to easily identify the item they want to create.
    Does anyone know the steps on how to proceed on these?
    I have read and researched about this and I found out that objects should be imported in Data Manager and the link between items should be mapped in Import Manager.
    I tried this first in Image, I was able to successfully import image. I tried adding the link first in existing item in data manager by right click on the Image field->Add/Link New... -> I was brought to the screen where I should add the image again, so I added ti again and there I was able to link the image and the item.
    I understand that for the image to be available in the end-user's internal catalog screen, I should modify UI Configuration. So I added the Image field by going to Customize Display Tab-> and adding it in the Item Lists, Cart Preview, Compare, Item details radio button. But when I checked on end-user's internal catalog screen, Image column is still not there.
    I believe PDF and Image has the same process. But how could I add the link between image and item for the entire catalog items?
    Please also help on how to activate the Hyperlink and Scale price functionality.
    Thank you so much!

    Dear Poster,
    As no response has been provided to the thread in some time I must assume the issue is resolved, if the question is still valid please create a new thread rephrasing the query and providing as much data as possible to promote response from the community.
    Best Regards,
    SDN SRM Moderation Team

  • When I ask Siri the stock price for MBL (other codes work fine), my iphone 5 crashes - does this happen to anyone else?

    When I ask Siri the stock price for MBL (other codes work fine), my iphone 5 crashes - does this happen to anyone else?
    It doesn't shut down completely, but mid-response the Apple shows and then it pops up to put in my pin.

    Nope nothing yet - a few friends have true it and have the same reaction."

  • Moving average price and standard price

    Dear All,
      Its simple question can any one explains me what is the difference between moving average price and standard price and how the posting will happen with these two price controls and what will get updated.

    Dear Tiru,
    There are two types of price control as below:
    a)Moving Average Price (MAP):
    -If PO and or Invoice price was differ from material master record, the difference was posting
    to stock account. Therefore the valuation price will change.
    b) Difference between a PO price or invoice price and the material master are posted to price
    difference account(PRD). As a result, the price in material master remain same.
    Example:
    Material Master Record:
    Total Qty: 10, Total Value 20, Price 2
    Scenario:
    PO: 10pcs at 2.50 EUR/PC
    Good receipt 10 pc
    Invoice 10 pc at 2.50 eur/pc
    a) MAP:
    Posting:
    Stock Account GR 25 +
    GR/IR Clearing    GR  25 -, IR 25 +
    Vendor Account  IR 25 -
    New Material Master ,Result:
    Total Qty = 20
    Total value = 45
    Price = 2.25
    b) Standard Price:
    Posting:
    Stock Account  GR 20 +
    GR/IR Clearing    GR  25 -, IR 25 +
    Vendor Account  IR 25 -
    Price difference Account(PRD)  GR 5 +
    New Material Master ,Result:
    Total Qty = 20
    Total value = 40
    Price = 2.00
    Hope this help.
    Loke Foong

  • MD04 filter-SAP00002-requirements and stocks

    Hi All Gurus,
    We have developed a Z-Report using function Module MD_STOCK_REQUIREMENTS_LIST_API to get stock report.
    My requirement is to get the shortage report with MD04 -> Selection Rules SAP0002 Requirements and Stock ( It exclude Open PO , PR etc.)
    I canot see this data ( AVAILABLE QTY COLUMN ) in function Module MD_STOCK_REQUIREMENTS_LIST_API.
    Can any one let me know where can see these datas so that i can map up my requirement..
    Please guide
    Regards
    Su

    Dear Su,
    for the next time i advice you BAPI_MATERIAL_STOCK_REQ_LIST instead of MD_STOCK_REQUIREMENTS_LIST_API because this one is released  by SAP and contains in any case MD_STOCK_REQUIREMENTS_LIST_API  inside.
    About your requirement i thinks that the selection Rules SAP0002 Requirements and Stock ( It exclude Open PO , PR etc.) are tool for standard filter with some limits, i would advise you to implemented a logic in your custom report in order to calculate the avalaible quantity starting from requirement quantity , stock , and receipt quantity.
    The FM MD_STOCK_REQUIREMENTS_LIST_API contains already all the quantity necessary for this calculation and it could be more simple to implement.
    You would consider specially DELKZ field for figure out the postive element and the negative element.
    For example:
    MRP Ele Ind   Object
    FE     Production order
    BA     Purchase requisition
    LA     Shipping notification
    PP     Planned independent requirement
    SA     Simulation order
    KB     Individual customer stock
    VC     Order
    and so on.
    Let me Know if i have been useful for you
    Daniele

  • Modify consignment stock price determination

    Hello,
    We have a vendor consignment stock that must be evaluated with the current price at the reception of the goods in the system, not the price at the date of transfer to own stock or consumption. 
    Weu2019ve been advised that in standard SAP system this is not possible.
    The requirement is to change the price determination at TCode MB1B when the liability is created.
    Iu2019ve tried a user exit from MB1B, but I was only able to modify the value at the material document generated and not the accounting documents.
    Is there a user exit or any other suggestion to achieve this?
    Thank you,
    Edited by: tania_ztrn on Jun 15, 2011 3:08 PM

    Hi,
    It's not clear to me why you are talking about special procurement key and stock determination togehter.
    In SPRO > MM > IM > Stock Determination > Define Startegies for stockDetermiantion
    Here you have to maintain a stock determiantion group, rule and plant / group / rule combination as well as a stock determiantion table.
    In SPRO > MM > IM > Stock Determination > Assign SDR in the Applications
    - IM > assign the rule to mvt 261
    - Production order > assign it to the proper plant/order type combination
    In MM02 > Plant data view 2 > assign the stock determiantion group to the amterial master under proper plant/sloc comination.
    After these settings it should work.
    Regards,
    Csaba

Maybe you are looking for