Programming Assignment Help

Hello guys, I am a little rusty on my Java programming skills and I need some assistance with an assignment. I have created the program below and I keep getting the following error:
Exception in thread "main" java.lang.NullPointerException
*     at MemoryManager.main(MemoryManager.java:22)*
but I am not sure why. I created a class called MemoryTable, but have not set any methods yet (at the bottom). Any assistance is appreciated.
=========================================
import java.util.Scanner;
public class MemoryManager
     public static void main(String[] args)
          String partitionlength;
          int numofpartitions;
          Scanner input = new Scanner(System.in);
          System.out.println("How many partitions are there?");
          partitionlength = input.nextLine();
          numofpartitions = Integer.parseInt(partitionlength);
          System.out.println("There will be " + numofpartitions + " partitions.");
          MemoryTable[] mtable = new MemoryTable[numofpartitions];
          for(int i = 0; i < numofpartitions; i++)
               mtable.partitionsize = (100 + i);
               System.out.println(mtable[i].partitionsize);
_________________________________________________________________________import java.util.*;
public class MemoryTable
     int partitionsize;
     int memoryaddress;
     int access;
     int partitionstatus;
     public MemoryTable()
     partitionsize = 0;
     memoryaddress = 0;
     access = 0;
     partitionstatus = 0;
     public void SetPartitionSize()
     public void SetNumOfPartitions()

OK. I don't completely understand what you meant by that, but this is what I tried, and I still get the error.
================================
import java.util.Scanner;
public class MemoryManager
     public static void main(String[] args)
          String partitionlength;
          int numofpartitions;
          Scanner input = new Scanner(System.in);
          System.out.println("How many partitions are there?");
          partitionlength = input.nextLine();
          numofpartitions = Integer.parseInt(partitionlength);
          System.out.println("There will be " + numofpartitions + " partitions.");
          MemoryTable[] mtable = new MemoryTable[numofpartitions];
          for(int i = 0; i < numofpartitions; i++)
               mtable.partitionsize = 100 + i;
               mtable[i].memoryaddress = 0;
               mtable[i].access = 0;
               mtable[i].partitionstatus = 0;
               System.out.println(mtable[i].partitionsize);

Similar Messages

  • Introduction to java class program assignment help

    We are susposed to be writing a program that calculates the best angle for firing a cannon ball to get the best distance through different substances. My teacher and i could not see why the program was not working and i was wondering if anyone could spot what is wrong with the code. The program is susposed to go through theta from 0 - 90 and remember the best theta for the best distance. we were testing with the drag constant as 0 because the theta should be 45 but the program outputs 81 instead. The big problem is that my x value goes negtive which should not happen and this is where my teacher gave up because he was unable to see why. my code is below for the program.
    Thanks for the help in advance
    Brian
    import javax.swing.*;
    public class Cannon2
        private static final double g = -9.8;
        public static void main(String[] args)
            int theta = 0; // initilizes theta
            int maxtheta = 0;
            double speed = 100; // initilizes speed
            double dt = 0.01;
            double time = 0.0;
            double vx, vy, vx1, vy1, xpos, ypos, oxpos, dragconst;
            double x = 0;
            double y = 0;
            ypos = 0;
            xpos = 0;
            oxpos = 0;
            dragconst = Double.parseDouble(JOptionPane.showInputDialog(null, "Enter drag constant:"));
            while (theta <= 90)
                vx = speed * Math.cos(theta);
                vy = -speed * Math.sin(theta);
                x = 0;
                y = 0;
                ypos = 0;
                xpos = 0;
                while (ypos >= 0)
                    ypos = y + vy * time; // y position
                    xpos = x + vx * time; // x position
                    time = time + dt; // increments time
                    x = xpos;
                    y = ypos;
                    vx = vx - Math.pow(vx, 2) * dragconst; // velosity calculator for x
                    vy = (vy + g * time) - (Math.pow(vy, 2) * dragconst); // velosity calculator for y
                    System.out.println(ypos);
                    System.out.println(xpos);
                    System.out.println(theta);
                if (xpos > oxpos)
                 oxpos = xpos;
                 maxtheta = theta;
                theta = theta + 1;
          System.out.println("The best angle is: " + maxtheta);
    }

    Simple. Reread the Math.cos (and Math.sin) documentation:
    cos
    public static double cos(double a)...
    Parameters:
    a - an angle, in radians.
    Returns:
    the cosine of the argument.
    I don't think 90 is what you want...

  • Freely Programmed Search help in Std Comp

    hi,
    Is it possible to add freely programmed searh help in standard SAP Component.
    I have dynamically assigned Freely search help to Context attribute using  set_attribute_value_help method.
    Now new component to be used in seach help is made in different package and this component is used as Used Comp
    in Std Component.
    When I click on search help it gives error : Comp usage ZHelp doesnt exist.
    zhelp- My component name.

    You have to add the component usage to the Standard Component, just like you would add the Freely Programmed Search help component usage to any component that wanted to call the search help.
    Component usages can be added using the Enhancement Framework:
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/46/233f2189f74f08e10000000a114a6b/frameset.htm

  • Freely-programmed value help for a single ALV cell

    Greetings everyone,
    I have a freely-programmed value help that works beautifully when attached to the context element of a single field, but now I'm needing to use it in an ALV for a specific cell.  Is there a way to shut off the dropdown for all of the rows (cells) in the column where I don't need it?  Or, is there an appropriate workaround that can deliver the same results?
    I've found several posts that address similar issues, but nothing for this exact problem.
    Thanks,
    Jason Block

    I take it from reading your description what you want is a little more complicated than just controlling the read-only property on the input field. If I read you properly you still want to have all the cells in a column to be open for input, just on some of them you want to disable the value help.  Is that correct?  See these screen shots for clarification:
    If you focus on the the input field in the first row, you get the value help:
    http://www.flickr.com/photos/tjung/2714133068/
    However if you go to the second row and focus on the same input field in this column, you don't get the value help:
    http://www.flickr.com/photos/tjung/2714133094/
    If this is what you want, then buckel up because this was a challenging one.  The problem is that the value help specification is not done at the UI element level, but instead at the context attribute level.  Therefore it can't be as simple as controlling a property on the inputField itself.  What you will need to do is extend the context node that you have bound to the ALV.  You need to add a second version of the attribute that is bound to your input field.  In this second version you can set the value help specification to Disabled:
    http://www.flickr.com/photos/tjung/2713320505
    Notice from the screen shot that I also added another attirbute called CVAR (type STRING).  We will need that later.  It will be used to store which cell variant show be used on a particular row.
    Now we must go to the place in your code where you fill the context node with data.  You will need to copy the data from your primary attribute to your secondary one.  In my case I was copying the values from CARRID to CARRID2.  Of course for update, you would need to merge the data back together before saving it back to the database.  I also set a simple odd/even pattern of controller in the cell variant.  I assume you will have some actual business logic that controls this:
    data odd type boolean value abap_true.
       loop at lt_f_r_sflight[] assigning <ls_f_r_sflight>.
        clear ls_c_r_sflight.
        move-corresponding <ls_f_r_sflight> to ls_c_r_sflight.
        move <ls_f_r_sflight>-carrid to ls_c_r_sflight-carrid2.
        if odd = abap_true.
          odd = abap_false.
        else.
          odd = abap_true.
          ls_c_r_sflight-cvar = 'NOVH'.
        endif.
        insert ls_c_r_sflight into table lt_c_r_sflight[].
      endloop.
      lo_r_sflight->bind_table( lt_c_r_sflight[] ).
    Next is the logic in the initialization of the ALV.  We will need to create two input fields - each bound to the different context attributes. We will make the one the primary cell editor.  The other will become the cell editor of the cell variant.  We then tell the column where it can get its cell variant value from:
    DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
      lo_cmp_usage =   wd_this->wd_cpuse_alv( ).
      IF lo_cmp_usage->has_active_component( ) IS INITIAL.
        lo_cmp_usage->create_component( ).
      ENDIF.
      DATA l_salv_wd_table TYPE REF TO iwci_salv_wd_table.
      l_salv_wd_table = wd_this->wd_cpifc_alv( ).
      DATA l_table TYPE REF TO cl_salv_wd_config_table.
      l_table = l_salv_wd_table->get_model( ).
      l_table->if_salv_wd_table_settings~set_read_only( abap_false ).
      DATA input1 TYPE REF TO cl_salv_wd_uie_input_field.
      DATA l_column TYPE REF TO cl_salv_wd_column.
      l_column = l_table->if_salv_wd_column_settings~get_column( 'CARRID' ).
      CREATE OBJECT input1
        EXPORTING
          value_fieldname = 'CARRID'.
      l_column->set_cell_editor( input1 ).
      DATA input2 TYPE REF TO cl_salv_wd_uie_input_field.
      CREATE OBJECT input2
        EXPORTING
          value_fieldname = 'CARRID2'.
      DATA l_cv TYPE REF TO cl_salv_wd_cv_standard.
      CREATE OBJECT l_cv.
      l_cv->set_key( 'NOVH' ).
      l_cv->set_editor(  input2 ).
      l_column->add_cell_variant( l_cv ).
      l_column->set_sel_cell_variant_fieldname( 'CVAR' ).

  • Integrate Freely Programmed Value Help in Select option WDR_SELECT_OPTION

    Hello All,
    I have created Freely Programmed Value Help name (ZVALUE_HELP) by using IWD_VALUE_HELP.I have develop an application(ZSELECT_OPTION) which uses the resubale component WDR_SELECT_OPTION for select option.i want search help for one of my select option input field .
    i wrote the following code.
    *initalise the used component
    data lo_cmp_usage type ref to if_wd_component_usage.
    lo_cmp_usage =   wd_this->wd_cpuse_ci_serach_help( ).
    if lo_cmp_usage->has_active_component( ) is initial.
      lo_cmp_usage->create_component( ).
    endif.
    * add a new field to the selection
      WD_THIS->M_HANDLER->ADD_SELECTION_FIELD(
      I_ID = 'ZCI_STATUS'
      IT_RESULT = LT_RANGE_TABLE
      I_READ_ONLY = READ_ONLY
      I_OBLIGATORY = ABAP_FALSE
      I_VALUE_HELP_TYPE = IF_WD_VALUE_HELP_HANDLER=>CO_PREFIX_APPLDEV
      I_VALUE_HELP_ID   = 'ZVALUE_HELP'
    when i execute the select option application n click on search help button i got error "Component usage ZVALUE_HELP does not exist.
    Edited by: Abhilasha Dahare on Aug 3, 2011 11:10 AM

    hi Abhsilasha,
    I think your code is some thing wrong.
    you have to assign free value help like below method.
    in the attribute( the select option field ) properties, you will find input help mode property, in that select 'freely  programmed'.
    then you willl get some more fields, there you have to provide ZVALUE_HELP
    of follow reema suggestion in below link
    How to integrate a Search Help in a dynamically created Select-Option?
    Regards
    Srinivas
    Edited by: sanasrinivas on Aug 3, 2011 12:06 PM
    Edited by: sanasrinivas on Aug 3, 2011 12:10 PM

  • Finance Homework Help, Accounting Assignment Help, Business Homework Help, Math Homework help

    The site ACCOUNTINGHOMEWORKTUTORcom helps the students in Accounting Homework Help, Finance Homework Help, College Homework Help, Business Homework Help, Math Homework Help, Marketing homework help, statistics assignments help answers, economics assignment solutions.
    The website ACCOUNTINGHOMEWORKTUTORcom, which is, a Global community of Students and Subject Experts where Students can interact with Tutors/Experts to get the Homework Help/Solutions of their Queries/Assignments/Projects. As per the past track records of last four years, organization is committed towards Quality College Homework Help to the Students who want to become part of Homework Help Team.
    ACCOUNTING HOMEWORK TUTOR provides Homework and Assignment Help in all Subjects. The website can also help you with Essays & Research Papers. Most of the tutors and writers of the company are either PhD or Master degree holders in their respective subjects.
    Their Team is efficient in College Homework Help, Statistics Homework Help, Finance Homework Help, Accounting Homework Help, Business Homework Help, Chemistry Homework Help, Math Homework Help, Algebra Homework Help, and Science Homework Help etc.
    Tutors and writers are committed to fulfill the requirements and meet the deadline with the highest quality of writing. All essays are plagiarism free and are checked for plagiarism before being delivered to you. The dedicated team of academic writers has great experience and writing skills.
    All tutor/writers are highly qualified and trained to write all types of dissertations, essays, research papers, book reviews etc.. All writers write exclusively for them so that there is no problem of plagiarism. Also this ensures that a student gets the very same writer/tutor always for his series of assignments. The services ensure that the paper is delivered to the client well within deadline. This enables the student to review the work and ask for minor changes that he would like.
    The site ACCOUNTINGHOMEWORKTUTORcom deals into variety of subjects like Anthropology, Archeology, Arts, Biology, Business, Chemistry, Computers & Technology, Community Studies, Criminology, Ecology, Economics, Education, Engineering, English Language, Finance, Geography, Geology, History, IT (information technologies), International Studies and Diplomacy, Languages & Linguistics, Law, Leisure and Tourism, Literature, Mathematics, Media Studies, Music, Marketing, Management, Medicine & Health Care, Nursing, Philosophy, Political Science, Psychology, Programming, Religion, Science, Social Issues, Statistics, Teaching, Technology.

    Whenever It comes to my mind the word Accounting, I get really sick & weak to my kneels. It happens a lot. Once I came across www.accountinhomeworktutor.com
    The guys are really helpful in accounting homework help & finance assignment help for financial comparative analysis, case study analysis, ratio analysis.
    I recommend this to everyone out there.
    finance homework help

  • Event Handling for free programmed search help bond dynamically in SO

    Dear Expert,
    I met a problem of how to handle an event raised by a free programmed search help - (F4), and this F4 is invoked
    by a field defined in a Selection Option component (WDR_SELECT_OPTIONS) - SO. 
    The scenario is that I would like to update the SO after the user multiple select some entries in the F4. I could tranfer
    back all the value chosen in the F4 to the consumer SO, but I can not update the icon in the SO(e.g  in SO, multiple values will be
    displayed with a green arrow icon), because I could not define a handler in SAP standard component SO, and it looks like there is no chance to catch the event triggered at the end of selection in F4.  (this event belonged to this F4)
    Welcome any suggestions or ideas, Thanks very very much. 
    In Addition, I use this way to enable the F4 for SO
    lo_so_component->create_cmp_usage_group(
         name = 'F4_TRANSPORT'
         used_component = 'ZTRANSPORT').

    thanks all

  • How to created Freely Programmed F4 help in Select Options

    hi,all
       I have a probelm about how to created a Freely Programmed F4 help in Select Options,and put help value into select options field
      Thanks and Best Regards

    Hi Haung,
    You need to use FREE_HELP not the component name.
    Modify you code as below:
       LT_RANGE_TABLE_V = wd_this->m_handler_V->create_range_table( 'ZCYPHDATE' ).
      wd_this->M_HANDLER_V->add_selection_field(
          i_id                         = 'ZCYPHDATE'
          it_result                    = LT_RANGE_TABLE_V
          i_value_help_type            = if_wd_value_help_handler=>CO_PREFIX_APPLDEV
          i_value_help_id              = 'FREE_HELP'
          i_no_intervals               = abap_false ).
    Hope this helps you.
    Regards,
    Rama

  • I downloaded Adobe Acrobat XI Pro - I signed in and now all I get is the Adobe Download Assistant with a prompt to keep downloading the program or help page.

    I downloaded Adobe Acrobat XI Pro - I signed in and now all I get is the Adobe Download Assistant with a prompt to keep downloading the program or help page. How can I launch the actual program and not the Assistant?
    Under the download or application file I only have the Assistant program

    Moving this discussion to the Acrobat Installation & Update Issues forum.
    Isabellasf have you ran the installation files which were downloaded?  By default they are downloaded to the download folder within your User folder.

  • I have acquired windows office 2011 for my macbook but unable to open it. There are currently 3 files in the folder, 1 of which seems to be the actual program which is a hfs file. iv tried looking for programs to help me open it but failed

    i have acquired windows office 2011 for my macbook but unable to open it. There are currently 3 files in the folder, 1 of which seems to be the actual program which is a hfs file. iv tried looking for programs to help me open it but failed.
    when double clicking on the image it says unable to open and gives me the option to search the app store.
    any help would be much appreciated
    Adam

    Well, first, just make sure it's the Mac version and not the Windows version (which indeed would not run on your Mac). You say "Windows Office" which is why I mention it. I think you probably just mean "Microsoft Office" though.
    Next, is this on a disk (DVD), or did you purchase and download it from the Microsoft site?
    Matt

  • How to add Freely programmed input help in FPM Search UIBB?

    Hi Experts!
    We have a requirement to create search UIBB in which the input field should have a freely programmed input help.
    I see that WD_VALUE_HELP parameter can be set to the component name and it displays the freely programmed help as well in the application.
    However, I am still digging to implement the search help open and close events of the component.
    I have used the Freely programed value help standard demo object  " FREE_VALUE_HELP "  which shows the value in the help popup however, the selected value is not returned in the input field.
    I am also unable to find any Interface as provided for implementing OVS in search UIBB as well...
    Please help.

    Hi Aliaksandr,
    Thanks for your response.
    I have checked this WDA application demo_value_help .... but it is a normal WDA application.
    However, I want use freely programmed search help in Search UIBB using FPM.
    I found that we can provide the component name used as freely programmed search help in the attribute WD_VALUE_HELP of Interface IF_FPM_GUIBB_SEARCH.
    https://help.sap.com/saphelp_nw74/helpdata/en/03/f2474b6d9a49f4b5a3ed6f04decf22/content.htm?frameset=/en/56/d151c3ba7b4b2e82068a084cb991f3/frameset.htm
    And it displays the search help as well when I do F4 on the field of Search UIBB. But, we need to provide event handler for events - VH_WINDOW_CLOSED and VH_WINDOW_OPENED of the search help component (Component which is provided in WD_VALUE_HELP) some where in the Feeder class, in order to get the selecteed data from the search help, which I am unable to do.
    Do you have any idea of such implementation?
    Appreciate your response!

  • My MacBook get's hot really quick and then discharge's quickly without opening any program, please help.

    My MacBook get's hot really quick and then discharge's quickly without opening any program, please help.
    I have checked the cooling fan, and it's working, and I took it to an IT technician and he said my hardware is allright, so is it a problem from the OS it self??
    OS X(10.8.5)

    Restart with the Option key held down and the Mac OS X install disk inserted, provide the firmware password, click on the DVD, press the button with the straight arrow, access the firmware settings, disable the password, and use FireWire Target Disk mode. If you can't do that or it doesn't work, contact Apple.
    (38384)

  • Problem in Select Option Freely programmed F4 Help

    Hi All,
    I had a Component 'A'  where i used select option. I used Freely programmed search help for the select option field.
    If i click F4 in the select option field it will call one component in which i have one more select option in component B.
    In component B select option field if i manually entering value and search and click apply values button the values are comming in the select option field in component A.
    But if i pressing the F4 in Component B and search and click apply values the value are not comming in the Component 'A'.
    If i open again component B and closing it without any action the value is coming in component A.
    If i debugged and see the WDDOMODIFYVIEW of tHE WDR_SELECT_OPTION is not getting called for component A.In which it has Rendering delta method of CL_WDR_SELECT_OPTION.
    Any idea about this.
    Regards,
    Ganesh.

    hi Ganesh,
    i have read your post several time and i am still not able to get hold on your problem. Probably it is to do with your complex approach of nested select_option, i can not judge why you did this way. I would advice you to step back and see it for yourself
    1)if it is need to have nested select_option
    2)check component initialization and destroy
    2)check event subscriptions

  • Help required on Freely Programmed Input help

    Dear all,
    I have developed a component, say comp1, in which i have implemented the interface IWD_VALUE_HELP.
    In the respective view(MAIN) of Comp1 i have a dropdown which contains a list of company codes fetched from T001 table.
    Apart from these two, I have also embedded the Main view into the window WD_VALUE_HELP.
    Now, I have created another component, say Comp2, in which i Used the dynpro component Comp1, and also in the MAIN view of my Comp2. Now in the MAIN view of Comp2 I have created a input field from the node T001 in the context which contains the single attribute BUKRS type String. In the properties of the BUKRS attribute I have also changed the Input help to "Freely Programmed" and linked to the component for the Input help.
    After this, I have created the application for my component Comp2. When i run the application and when i press F4 on the input field i am able to get the window from Comp1 component, and a dropdown with values.
    Now the question is, How can i pass the value selected in that window of Comp1 into the input field of Comp2? we do the same in OVS, when ever a value is selected from the Hitlist, it will be cascaded into the input field, just like that i want to do here.
    Please suggest me how to do this, and also please tell when to go for Freely programmed Input help and its advantages.
    Thank you,
    Shashi.

    You can do as suggested already and use interface nodes and cross component mapping; but that is all really not necessary.  It creates a situation where you calling application is too dependent upon the freely programmed input help.  You want to try to avoid the situation where the calling application needs code or mappings to communicate with the input help.
    That is easy to do because the framework passes all the information you need into the freely programmed input help via the value_help_listener object. 
    Part of the Freeley Programmed Input Help Component should be the component interface IWD_VALUE_HELP.  This comes with a component controller method called SET_VALUE_HELP_LISTENER.  This allows your freely programmed value help to capture this object called listener of type IF_WD_VALUE_HELP_LISTENER. I generally just store it awa into a component controller attribute.
    With this listerner object you have direct access to the context attribute in the calling component. You can query information about the calling UI element and of course set values directly back into it.  The listener is a hugely helpful object and should be the way you interact with the calling component whenever possible.  Here is small example:
      set single attribute
      wd_this->value_help_listener->f4_context_element->set_attribute(
      exporting
        name = wd_this->value_help_listener->f4_attribute_info-name
        value = l_time

  • Freely Programmed Search Help

    Hi there,
    I have a WebDynpro application with two fields.  The first field has Dictionary search Help on it.
    The second field has a Freely Programmed input help.  The problem I am faced with is that the freely programmed search relies on the value of the first field to determine it's own values - i.e The first field is a contract, and the second field is an item on the contract.  So if the contract changes, so should the list of items provided in the Help.
    Now the way that this works is that the user selects a contract, then selects an item, then completes the fields in a PDF document.
    They press the button Save and Clear which saves the data, clears all the fields, and is then ready for the next lot of data.
    Although I can clear out all the fields, I don't know how to trigger the refresh of the Freely Programmed help.  The first time it is used it gets the right data, and after that it always shows the same data, - I just don't know how to trigger a refresh.  Basically I want it to refresh every time it is used!!
    Many thanks
    Jack

    Hello Jack,
    hmm... it should refresh itself, because you determine what goes in and out. Probably, you need to clean up some nodes in your freely programmed search help component as well i.e. upon leaving.
    Best regards,
    Thomas

Maybe you are looking for

  • A/R - Credit Memo ... document chain

    Hi Following procedure: Sales Order -> Delivery -> A/R Invoice has been done as usual. Now I want to issue an A/R credit memo and raise a new A/R Invoice with a different amount. Since all the documents are closed, how do I link the new A/R Invoice t

  • Interactive Report & Item Value in Page 0

    Hi, Is it true that Interactive Report query couldn't read item value from Page 0? I have this Interactive Report region using the :P0_EMP_SEQ in the where CLAUSE, i found out that the value is always blank/NULL. I created a normal Report region to t

  • How do I stop getting updates for games through the app store on my macbook?

    I'm continually getting updates for games (also for the usual stuff, but that's fine), is there a way to edit what updates you get?  Thanks!

  • US GAAP consolidation

    Our client has multiple company codes in different companies. The local currencies are different for each country's co codes Group currency is USD At year end, when they run financials in F.01, in the consolidation ledger 0L, they first run with curr

  • Posting MIRO with reference to MIGO document number

    Hi, Is there any way of posting a vendor invoice in MIRO, taking MIGO document number as the reference instead of PO or Delivery Note reference? Muru