Problem in assigning a variable value to another one

hi
i am just trying to develop class calculating the selling price of car as 15% of the purchase price addeed on the purchase price
and i developed the next code which is a part of longer code :
package cardealer;
public class Car4Sale extends Car {
  public static void main(int[] args) {
    Car4Sale pur , sell; //pur is purchasing price , sell is selling price
    sell = pur *(1+ 0.15) ;
}the proplem is in the line : sell = pur *(1+ 0.15) ;
the program says: the variable pur might have not been intialized . operator * can not be applied .
Note: when i delete this line the variable pur returns intialized in the upper line

Here is a simple example of what (i think) your
trying to do.
//Car class
public class Car
     private double purchasePrice;
     private String type;
     public Car(double price, String type)
          this.purchasePrice=price;
          this.type=type;
     public double getPurchasePrice()
          return purchasePrice;
     public void setPurchasePrice(int price)
          this.purchasePrice = price;
     public String getType()
          return type;
     public void setType(String type)
          this.type = type;
//Car Sales class
public class CarSales
     private Car car = new Car(100,"Porsche");
     private double sellingPrice;
     public static void main(String[] args)
          CarSales cs = new CarSales();
System.out.println("Car Type :"
:" +cs.car.getType());
System.out.println("Car Purchase Price
ce :"+cs.car.getPurchasePrice());
System.out.println("Car Selling price
ce
:"+cs.getSellingPrice(cs.car.getPurchasePrice()));
     public double getSellingPrice(double purchasePrice)
          return purchasePrice += (purchasePrice / 100) *15;
}modify it to suit your needs.thank you for this great reply but what i am really looking for is to enter attributes for the car. the attributes are number , manufacturer , size, color . after then adding the purchase price in a subclass and calculating the selling price .
Ihave no problem whith input code but i am not sure about it is how to deal with these attributes

Similar Messages

  • How to derive a variable value from another variable of a different IO?

    Hi Gurus,
    I am aware that using BEx variables and Customer Exit you are able to derive a variable value from another variable of the same infoobject (for example, Fiscal Year/Period (0FISCPER) and Calendar Day (0CALDAY)).
    However, is is possible, using the same approach to derive a variable value from another variable that is in a different InfoObject? (for example, Input Fiscal Year/Period (0FISCPER) but derive Output of Required Start Date (0REQSTDAT))?
    There are 2 BEx variables involved,
    1) A user entry variable that is restricted in 0FISCPER
    2) A customer exit variable that is restricted in ZREQSTDAT
    In CMOD under EXIT_SAPLRRS0_001, Include ZXRSRU01, the code (I assume, correct me if I'm wrong) should perform 3 functions in I_STEP = 2,
    1) After the pop up, capture user entry of Fiscal Year/Period
    2) Identify or convert Fiscal Year/Period to Calendar Day range (unsure on how to code this portion)
    3) Use the Calendar Day to lookup on matching Required Start Date and display all Required Start Date that matches. (unsure on how to code on this portion)
    Hope to hear your thoughts soon.
    Regards,
    Eric

    Hi Shanthi,
    I've made the necessary adjustments. The only difference in my code is,
    Instead of,
    If I_VNAM = 'ZREQSTDAT'
    I use,
    CASE I_VNAM.
    Instead of,
    PARAMETERS: ZFISCPER TYPE /BI0/OIFISCPER.
    ZYEAR = ZFISCPER(4).
    ZMM = ZFISCPER+4(3).
    I use ,
    This is the Customer Exit Variable in ZREQSTDAT
    WHEN 'ZRSD_CX'.
    The loop I use for the User Entry Variable in 0FISCPER-ZFYP_IN
      LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
          WHERE VNAM = 'ZFYP_IN'.
        IF SY-SUBRC = 0.
            CLEAR L_S_RANGE.
    ZYEAR = LOC_VAR_RANGE(4).
    ZMM = LOC_VAR_RANGE+4(3).
    The codes were checked with no errors.
    However, when I input the Fiscal Year/Periods and hit 'Execute'. The report went blank, not sure what is the cause. I've tried it several times. No error message appeared.
    Regards,
    Eric

  • Assigning variable value to another variable

    I want to assign value from one variable with type DATETIME to another variable which has type STRING.
    E.G: I need to convert this variable P_CreatedDate of type DATETIME to STRING variable CreatedDate.
    Can someone help me in C# script. Im using SSIS script task.
    Thanks in advance.
    ZK

    I have a requirement where I need to convert following datetime variable value into the string vaiable format.
    Here is the example: 
    7/23/2014 11:24 PM
    I need above datetime to be converted into following string format
    2014-01-01 03:15:01.470
    yyyyMMdd HHmmssFFF
    Thanks in advance.
    ZK

  • Unable to assign the variable value

    Hi,
    I am trying to capture the error message into a variable using statement in the Refreshing tab :
    Select '<%=odiRef.getPrevStepLog("MESSAGE")%>' from dual
    After getting the error log into variable, I am making a call to Scenario which will generate a file and email it stating the error log.
    Now the issue is when i assign this variable to the Scenario variable it throws the following error:
    com.sunopsis.tools.core.exception.SnpsSimpleMessageException: Invalid parameter
         at com.sunopsis.dwg.function.SnpsFunctionBase.getSunopsisApi(SnpsFunctionBase.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execIntegratedFunction(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSqlS.treatTaskTrt(SnpSessTaskSqlS.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
         at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
         at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
         at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
         at com.sunopsis.dwg.cmd.e.i(e.java)
         at com.sunopsis.dwg.cmd.g.y(g.java)
         at com.sunopsis.dwg.cmd.e.run(e.java)
         at java.lang.Thread.run(Unknown Source)
    If i set the variable with any default value, it successfully makes a call to the scenario and generates the file.
    Please help!
    Thanks,
    Ritika

    Hi,
    i created a variable and assigned the value to another variable in a procedure, am getting the following error, as it says in the error i don't have any ";" that is causing the problem.
    the variable name is table_nm
    inside the procedure am assigning the value to lv_table_nm :=#SESSNAME.table_nm;
    If i change the variable name tos ome constant or any other value, the package is working fine. Any ideas why am getting error assigning the variable?
    6550 : 65000 : java.sql.SQLException: ORA-06550: line 1, column 294:
    PLS-00103: Encountered the symbol ";" when expecting one of the following:
    ( - + case mod new not null <an identifier>
    <a double-quoted delimited-identifier> <a bind variable>
    continue avg count current exists max min prior sql stddev
    sum variance execute forall merge time timestamp interval
    date <a string literal with character set specification>
    <a number> <a single-quoted SQL string> pipe
    <an alternatively-quoted string literal with character set specification>
    <an alternatively
    java.sql.SQLException: ORA-06550: line 1, column 294:
    PLS-00103: Encountered the symbol ";" when expecting one of the following:

  • Assign container with value of another container

    Hello,
    I would like to assign the parameter (defined as referenced container) of a subsequence with the value of another container. Something like this:
    "Parameters.OUT_CONSTANTS = FileGlobals.CONSTANTS"
    But in my expression windows, I get the message:
    "Evalutation error
    Variable or property types do not match or are not compatible."
    What do I have to do to make it works?
    Cheers,
    Risotto

    Hi Risotto,
    One concept that you need to watch out for is making sure that the variables defined inside both of your containers need to have the same names. So if your Parameter container had a numeric variable called "Temp", then your FileGlobals container would need a numeric variable called "Temp". The naming conventions need to be the same as well as the data type. The order of the variables inside the cluster doesn't matter. If you don't use the same names for the variables, you will receive the error you mentioned.  Attached is a short snippet of code that shows you how to correctly assign containers. 
    Hope this helps!
    Jonathan N.
    National Instruments
    Attachments:
    Example.seq ‏29 KB

  • How to assign a variable value to crystal report viewer formula with CR2008

    Hi ,
    I am using crystal reports 2008 and i am not able to find how to assign  variable value  to crystal report viewer formula.
    In CR 8.5 , i used to have crystalreport1.Formulas(0) = variable1
                                             crystalreport1.Formulas(1) = variable2
    but, i don't find similar kind  in crystal reports 2008.
    How can i achieve the same functionality using crystal reports 2008.
    Thanks in Advance
    Regards,
    Ramnath

    Hi,
    Can i anyone help me out with this.
    I am generating crystal reports in vb6 using CR 8.5 and vb6 and below is the code snippet for the same
    CrystalReport1.Formulas(0) = "PrintTitle= '" & strMyTitle & "'"
    CrystalReport1.Formulas(1) = "FromDate= '" & MskFromDate.Text & "'"
    CrystalReport1.Formulas(2) = "ToDate= '" & MskToDate.Text & "'"
    Please let me know how the same functionality can be achieved in VB.Net using Crsytal reports 2008
    Any code snippet would be of great Help.
    Thanks in Adnvance.
    Ramnath

  • Can we assign jython variable value into ODI variable?

    Hi Team,
    We are trying to save jython variable value into ODI variable so that ODI variable can use in later steps.
    we are facing failure regards same.
    Please suggest us so that we can use ODI variable value in later steps.
    Thanks
    Ankush.

    See if this post help you :- How to assign value for a ODI variable from Jython Script
    Doc id 424579.1 on metalink should help.

  • Filling up a variable value from another variable

    Hi,
    I have two date fields, one calmonth characteristic ZCALMON (as char) and other calmonth charactaeristic 0CALMON as time dimension (standard bw).
    But at query level, I would like to user enter only one variable value 0PCALMON for 0CALMON (say only for date characteristic as time dimension). This date variable value should get copied to other date characteristic ZCALMON (as char).
    I can do this by using the customer exit varibale (without writing any abap code) and using the copy variable from other variable options. But I am not able to use the offset on ZCALMON.
    How can i Use offset using customer exit variable on ZCALMON.
    cheers
    raj

    Hi,
    you can use customer exit variable which will read the value of the 0calmonth variable and pass it to the zcalmonth.
    While populating the value, do the calculation or the off-set and send the value to zvcalmonth (Variable).
    WHEN 'ZVCALMON'.
       IF i_step = '2'.
      Loop at i_t_var_range into i_s_var_range where vnam = '0PCALMON' .
        zdat = i_s_var_range-low.
      endloop.
          CALL FUNCTION 'GO_BACK_MONTHS' *Sample Function
            EXPORTING
              currdate   = zdat
              backmonths = '012'
            IMPORTING
              newdate    = from_period.
          CALL FUNCTION 'GO_BACK_MONTHS' *Sample Function
            EXPORTING
              currdate   = zdat
              backmonths = '000'
            IMPORTING
              newdate    = to_period.
          CLEAR l_s_range.
          lyear  = from_period+0(4).
          lmon   = from_period+4(2).
          lday   = from_period+6(2).
          CONCATENATE lyear lmon lday INTO l_s_range-low.
    Hope you got it
    Regards
    Happy Tony

  • Can we Pass two variable values in to one Varaible which is Cust Exit?

    Hi all,
    Can we pass two Variable values to a Variable which is Custexit?(For Example posting Period and the fiscalyear in to the FicalPeriod )
    Regards
    Kiran

    Hello,
    For that example you had to "convert" both post period and fiscalyear into fiscalperiod, and yes it is possible, but not throwing up the two values, you had to do it yourself in the user exit code.
    Diogo.

  • Issue with customer exit for copying one variable value to another

    Hello Gurus,
    I need to copy the value of a single value variable into another single customer exit variable.
    I coded as below.
      WHEN 'customer_exit_var'.
        IF I_STEP = 2. "after the popup
          LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
          WHERE VNAM = 'user_input_Variable'.
            CLEAR L_S_RANGE.
            L_S_RANGE-LOW = LOC_VAR_RANGE-LOW.
            L_S_RANGE-HIGH = ''.
            L_S_RANGE-SIGN = 'I'.
            L_S_RANGE-OPT = 'EQ'.
            APPEND L_S_RANGE TO E_T_RANGE.
            EXIT.
          ENDLOOP.
        ENDIF.
    I used the condition <= for the customer exit variable in the report. But, it is considering only single value, but not all the values <= to the give value.
    Please help me in this regard,
    Thanks,
    Aarthi.

    Thanks for your immediate response Govind.
    My report is restricted based on two dates. Date1 and Date2. Need to consider all records whose dates are <= Date1 and <= Date2.
    Date1 and Date2 should have same values. But user inputs only Date1.
    So, I created Date1 as Single, User Input Variable restricted the query with <=Date1.
    Next I created Date2 as Single, Customer Exit Variable and restrcited the Query with <=Date2.
    In CMOD I used the above code to assigne Date1 Value to Date2.
    When I execute the report, say I give todays date in the report (Dec, 12, 2007). Date2  has to consider all the values <= Dec 12, 2007. But, in my case it is considering only Dec 12, 2007, but not the before dates.
    So, Please help me in solving this problem.
    Thanks,
    Aarthi.

  • Getting a variable value from another class

    Is there any way to get the value of a variable from another class? I have a file that calls another that does some checking then gives a true or false. The place the checking is done is inside an ActionListener I want to use that value in the file that calls the second. Any help would be great.

    in 'another class', implement a method,
    public boolean isCheckedOutOK( Object obj )
    do the comparison in that method (use a suitable argument)

  • Automation of assigning Substitution Variable Values

    Hi All,
    I have 3 substitution variables with values in my server as follows:
    Prev Month - "January"
    Curr Month - "February"
    Next Month - "March"
    I want to automate the assigning of values to the substitution variables so that in the next month, the values change automatically as follows:
    Prev Month - "February"
    Curr Month - "March"
    Next Month - "April"
    Is there any way available to accomplish the above task.
    Any help appreciated.
    Thanks,
    Raja

    Ditto Sean V. Except the date logic I built into a Perl script. So basically one answer is to use your favorite scripting/programming language to do the date manipulation and either pass to a MAXL script as a variable, or to build the MAXL script dynamically

  • Pass The Variable Value to another class

    maybe just simple question, but i can't find out how to resolve it
    I want to use the ResultSet for my database connection result to another class ..
    this is my code
    private static select(){
    String URL = "jdbc:mysql://localhost/Chat";
    String username = "root";
    String password ="";
    try{
    Class.forName("com.mysql.jdbc.Driver")
    }catch(exception e){
    System.out.println("Failed to load MySQL driver");
    Statement stmt = null;
    Connection con = null;
    try{
    con = DriverManager.getConnection(URL,username,password);
    stmt = con.createStatement();
    ResultSet RS = stmt.executeQuery("SELECT * FROM message;");
    while (RS.next()){
    String command = RS.getString("command");
    String source = RS.getString("source");
    String target = RS.getString("target");
    RS.close();
    stmt.close();
    con.close();
    i want to retrieve those three string variable "command", "source", "target"
    for example
    public void run(){
    while(true){
    try{
    select()
    ...... next line is to retrive those three value of string
    how can do it ?
    TIA

    than you limeybrit9 for the answer..
    i get the point, buat i still can't figure it how exactly it has to be done ..
    let me try with arrayList
    private static select(){
    String URL = "jdbc:mysql://localhost/Chat";
    String username = "root";
    String password ="";
    String[] result = new String[3];
    Arrays array = new Arrays();
    try{
    Class.forName("com.mysql.jdbc.Driver")
    }catch(exception e){
    System.out.println("Failed to load MySQL driver");
    Statement stmt = null;
    Connection con = null;
    try{
    con = DriverManager.getConnection(URL,username,password);
    stmt = con.createStatement();
    ResultSet RS = stmt.executeQuery("SELECT * FROM message;");
    while (RS.next()){
    Result[0] = RS.getString("command");
    Result[1] = RS.getString("source");
    Result[2] = RS.getString("target");
    array.asList(Result);
    RS.close();
    stmt.close();
    con.close();
    and i still dont know how to pass those arraylist in other class

  • Variable value from another variable

    Hi all,
    I created a query where one variable fill nother variable with following abap code:
    when 'ZODACE'.
        tables: /BIC/AZSD_O0100,
                /BIC/AZSD_O0200.
        ranges: r_createdon for /BIC/AZSD_O0100-CREATEDON.
    break-point.
        if i_step = 2.
          loop at i_t_var_range into loc_var_range
                  where vnam = 'ZDATADOC'.
            clear r_createdon.
            r_createdon-low    = loc_var_range-low.
            r_createdon-high   = loc_var_range-high.
            r_createdon-sign   = 'I'.
            r_createdon-option = 'BT'.
            append r_createdon.
            exit.
          endloop.
          select DOC_NUMBER into
                 /BIC/AZSD_O0100-DOC_NUMBER
                 from /BIC/AZSD_O0100
                  where /BIC/ZAUDAT in r_createdon.
            select single * from /BIC/AZSD_O0200
          select * from /BIC/AZSD_O0200
                   where refer_doc = /BIC/AZSD_O0100-DOC_NUMBER.
              clear l_s_range.
              l_s_range-low = /BIC/AZSD_O0200-refer_doc.
              l_s_range-sign = 'I'.
              l_s_range-opt  = 'EQ'.
              append l_s_range to e_t_range.
          endselect.
          endselect.
        endif.
    The variable are:
    ZODACE based on IO 0REFER_DOC with customer exit
    ZDATADOC based on IO ZDATU with manual entry
    After wich end-user digit a data in ZDATADOC popup I take ODOC_NUMBER in order item ODS ZSD_O01 where ZDATADOC=CREATEDON.
    With 0DOC_NUMBER I go to delivery item ODS ZSD_O02 and I take the corresponding 0REFER_DOC and then I fill variable ZODACE.
    0REFER_DOC is in row of the query.
    When I start the query I receive the following error message:
    Error for variable in the customer exit ZODACE
    and in debug i find this message:
    System error in the program CL_RSR_REQUEST and Form GET_SETXX_WA
    How can I do please?
    Thanks in advance
    Gianmarco

    0DOC_NUMBER   type-CHAR lenght-10
    0REFER_DOC      type-CHAR lenght-10
    ZAUDAT               type-DATS lenght-8
    0CREATEDON      type-DATS lenght-8
    Can you help me please?
    Thanks a lot

  • PL/SQL Looping a table and copying some values to another one...

    hi all!!!
    i'm totally new to pl/sql, and i need to create an interaction to do the following..
    my scenario is:
    i have a table called "references" that contains 2 columns (new_id, old_id).
    then i have another table called "ref" which also contains 2 columns (old_id, other_id).
    ok the point is this:
    in the table references i have stored the references between 2 products (the old one and the new one) by storing their ids.
    now what i have to do by knowing this, is to insert in the table "ref" a new entry for every old_id that is already stored there, but changing it with the new_id that i can get from the other table (references).
    let's see an example:
    table references:
    new_id - old_id
    11 - 3
    12 - 7
    13 - 5
    table ref:
    old_id - other_id
    3 - tu7r
    7 - asduih
    7 - anotherone
    7 - 44444
    5 - 6754f
    so the result that i want is that the new ids (11,12,13) has to be copied to the table "ref" with the same "other_id" as their correspondants in "references" table.. the result would be:
    table ref:
    old_id - other_id
    3 - tu7r
    7 - asduih
    7 - anotherone
    7 - 44444
    5 - 6754f
    11 - tu7r
    12 - asduih
    12 - anotherone
    12 - 44444
    13 - 6754f
    i don't know how to build up a loop or something to reach this aim!!
    thanks for your time guys!!!
    Edited by: ElMazzaX on Nov 17, 2011 3:15 PM

    You do not need pl/sql to do this.
    If I understand your datamodel correctly, this join will get you those records you need to insert:
    select
    references.new_id, ref.other_id
    from references
    join ref
       on ref.old_id = references.old_id;Try that select - it it works, then you can simply do:
    insert into ref (old_id, other_id)
    select
    references.new_id, ref.other_id
    from references
    join ref
       on ref.old_id = references.old_id;SQL is quite enough - no PL/SQL loop necessary ;-)

Maybe you are looking for

  • How to develop/print a report wider than 8.5 inches, why cant we landscape

    Hi All Gurus, I am new to Oracle Reports. I have a problem, I have a report that has rows longer than normal A4, A5, A6 paper width, so report lines either tend to go on next page or on next line of the same page. Also Oracle Report is not allowing m

  • How to Tether Alltel LG Tritan CDMA phone Mac OS X

    This is a great little phone, and if you buy it through Walmart you get UNLIMITED internet. Okay, there are no USB modem drivers for this phone, so you have to use bluetooth. First pair your computer to the phone. Set the phone to "visible" (Icon but

  • Rescale images based on largest dimension

    I want to batch resize photos for web output. Ideally I'd like to set a max size based on whether they are vertical or horizontal, such as 400 high if vertical or 500 wide if horizontal (without presorting into tall and wide folders). If this is not

  • Link Behavior Question

    Good Morning, How do I ensure my current page values will be accessible thru the DataActionContext when a link is pressed? Thanks

  • Using files from Windows in Mac

    If I create a webpage design in dreamweaver on a windows pc and save the file, can I then open that same file on a Maccomputer running dreamweaver?