Can u rectify my mistakes ??

well, i am very new to java programming, and have been into it for no more than 15 days ... i have a assignment, which i have worked as below. can anyone point my mistakes (how silly they might be) and if possible, tell me what is to be done to achieve the degree of correct code writing ?
the question is here
http://cs.albany.edu/~haas/cs310.html
(program3)
my code is as follows >
import java.util.*;
public class lp {
public double info;
public lp rest;
public lp(double info1, lp rest1)
public int(free_space)
public lp (data_memory)
info = info1;
rest = rest1;
public static void show_list(lp ptr1)
lp i;
for(i=ptr1;i != null;i = i.rest)
System.out.print(i.info + " ");
static lp read_list()
Scanner console = new Scanner(System.in);
lp answer = null;
double next_element;
next_element = console.nextDouble();
while(next_element >= 0)
answer = new lp(next_element, answer);
next_element = console.nextDouble();
return answer;
/* This function inserts a new element in an ordered lst, in the correct position.
* It returns a pointer to the new list. */
static lp insert(double new_num,lp ptr1)
/* If the list is empty, or the new element is <= the first element, put the\
* new element at the front. That is your answer. */
if((ptr1==null) || (new_num <= ptr1.info))
return new lp(new_num,ptr1);
else
/* At this point we know two things: the list is not empty, and the new
* element is > the first element. Move ptr2 up the list as long as this
* condition holds: there is an element after ptr2, and the new element is
* > the one after ptr2. */
lp ptr2 = ptr1;
while(ptr2.rest != null && new_num > data_memory[ptr1.rest])
ptr2 = ptr_memory[ptr2];
/* At this point we know that either there is no element after ptr2, or the
* new element is <= the one after ptr2. In either case, the new element goes
* after ptr2 */
ptr1.rest = new lp(new_num,ptr1);
/* We are not inserting the new element at the front, so ptr1 points to
* the answer. The value of ptr1 has not chnaged, but the list it points to
* has changed. */
return ptr1;
/* This function makes a copy of a linked list. The copy contains the same elements
* but they are in different places in the array. Changing the old linked
* list will not change the copy. */
public static int copy(lp ptr1)
/* This is the easy case. */
if(ptr1==null)
return null;
else
/* This is the first node of the copy. */
int ans = free_space();
/* It contains the same data as the first node of the old list. */
data_memory[ans] = ptr1.info;
/* This variable always holds the last node that we copied. Right now,
* its value is ans -- the node we copied in the last line. Note
* that the last node we copied has no successor. In order to
* give it a successor, we have to copy one more node! */
int last = ans;
/* This is the part of the old list that we still have to copy --
* everything except the first node. */
int old = ptr1.rest;
/* Keep copying until the uncopied part of the old list becomes empty. */
while(old!= null)
/* A new node for the copy. */
int new_node = free_space();
/* It contains the same data as the first node in the uncopied part of the
* old list. */
data_memory[new_node] = data_memory[old];
/* It is the successor to the last node the we copied. Remember that
* up till now, that last node had no successor.*/
ptr_memory[last] = new_node;
/* Now that we have finished copying, the new node becomes the last node
* that we copied. */
last = new_node;
/* We have copied one node, the uncopied part gets shorter by one. */
old = ptr_memory[old];
/* It is still true that the last node we copied has no successor. Since
* there is nothing left to copy, its successor is NULL_PTR. */
ptr_memory[last] = null;
/* We return the first node that we copied, because it is the first node
* of the copied list. */
return ans;
public static lp read_list2()
Scanner console = new Scanner(System.in);
return read_list3(console);
public static lp read_list3(Scanner scanner1)
double next;
next = scanner1.nextDouble();
if(next < 0)
return null;
else
return new lp(next,read_list3(scanner1));
// The function accepts number of elements from the user. It then asks for any element to entered
// it then inserts the element in the list and copies the same to the linked list to print the result
public static void main(String args[])
System.out.println("");
System.out.println("input list");
Scanner sc = new Scanner(System.in);
double new_num = sc.nextDouble();
double value = new_num();
lp list2 = new lp(7.0,new lp(5.0,new lp(6.0,null)));
show_list(list2);
list2 = read_list();
show_list(list2);
System.out.println("");
System.out.println("input number to insert");
System.out.println("");
System.out.println("new list");
System.out.println("");
System.out.println("copy");
Scanner sc = new Scanner(System.in);
insert((lp (new_num)),lp (ptr1));
copy (ptrl);
}

darshshinde wrote:
well, i am very new to java programming, and have been into it for no more than 15 days ... i have a assignment, which i have worked as below. can anyone point my mistakes (how silly they might be) and if possible, tell me what is to be done to achieve the degree of correct code writing ? You should review the Java tutorial available here http://java.sun.com/docs/books/tutorial/java/index.html
Then re-design your program so that it actually uses Objects which your's currently does not really. You should have an "ip" or whatever it is class and this class should have non-static methods that you call that operate on it.
It appears that the lp/Ip class is supposed to be some sort of linked list. I would work on the basics of this first.

Similar Messages

  • When uploading my formatted resume to my Apple Jobs profile, I am always presented with a c:\fakepath message and the resume does not upload. How can I rectify this?

    When uploading my formatted resume to my Apple Jobs profile, I am always presented with a c:\fakepath message and the resume does not upload. How can I rectify this?

    Add this one to the list of thinks that don't work on the Apple Job Board. It looks like Apple is using ADP's VE (Virtual Edge) technology to run this system, and I've been stupified by the number of features that are just broken, or so poorly thought out by ADP as to be unusable, (certainly for webkit and mozilla browsers at least: I didn't bother checking IE.)
    Here are a few highlights:
    "My Job List", list of jobs applied for, seems to max out at three. You can apply for more than that, but you can only see the first three.
    "Search Using Your Resume" feature yields few or no results, even when the pasted text contains only common, exactly matched words like 'Design' or 'Engineer'.
    The missing resume upload, described in this thread.
    "My Job Agent" seems to never flag anything, at least it hasn't ever for me despite pretty loose criteria.
    Agent's created using "My Job Agent" eventually just disappear, which is fine because they don't seem to work.
    When updating a profile, acknowledging the 'Terms' happens twice in a row. 
    Job seekers can only supply one cover letter despite being able apply for several jobs.
    Pagination for search results only appears at the top of the page, so it's necessary to scroll down through each page, then up to the top again to proceed to the next page.
    Well, I'm sure there are others, but you get the idea. I hope the Apple folks can fix this, (or twist ADP's arm to fix it,) so it better represents the quality of experience that Apple is so respected for consistently delivering.

  • I have previewed my book but after cliking BUY BOOK it compiles it OK but then it always states an error after of during uploading it to the store.  How can I rectify this?

    I have previewed my book but after cliking BUY BOOK it compiles it OK but then it always states an error after of during uploading it to the store.
    How can I rectify this?

    I have previewed my book but after cliking BUY BOOK it compiles it OK but then it always states an error after of during uploading it to the store.
    How can I rectify this?

  • HT1725 I've purchased an entire album but some of the songs stop playing midway through. How can I rectify this?

    I've purchased an entire album but some of the songs stop playing midway through. How can I rectify this?

    Welcome to the Apple Community.
    Try deleting the problematic file (electing to remove original file if/when prompted) and then re-downloading the file from the iTunes store.
    You can re-download content purchased from the iTunes store (availability varies depending on location) using the purchased option from the Quick Links section in the top right corner of the iTunes homepage in your iTunes application on your computer.
    You can re-download content purchased from the iTunes store (availability varies depending on location) using the purchased option at the bottom of the screen of the iTunes app (or video app) on your iOS device.
    If the problem re-occurs, select the content which is causing a problem and use the 'Report a problem' button in Your Purchase History using your computer.

  • TS3899 My emails are showing as 'read' but they are not read!  How can I rectify this problem?

    My emails suddenly keep showing as 'read' but they are unread.  How can I rectify this problem?

    Is the folder pane collapsed? View(or AppMenu/Options)/Layout/Folder Pane. Otherwise, deleting foldertree.json might fix it:
    http://kb.mozillazine.org/Toolbar_or_windows_layout_not_working

  • HT3702 My credit card is declined without apparent reason. How can I rectify this?

    My credit card is declined without apparent reason. How can I rectify this? I do not want to use another card because of children securiity reasons.

    If it's a credit card (I don't think that debit cards are still accepted) then is it registered to exactly the same name and address (including format and spacing etc) that you have on your iTunes account, it was issued by a bank in your country and you are currently in that country ? If it is then you could check with the card issuer to see if it's them that are declining it, and if not then try contacting iTunes support and see if they know why it's being declined : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page

  • My iPod touch's menu button literally sank in and now I am unable to use my iPod totally because I cannot press the menu button at all. Can Apple rectify this if I send it to a service center?

    My iPod touch's menu button literally sank in and now I am unable to use my iPod totally because I cannot press the menu button at all. Can Apple rectify this if I send it to a service center?

    You should definetely contact an apple store! If your warranty is valid they will probably fix it for free. Until then go to settings, general, accessibility, assisive touch and turn it on. A circle will appear that does exactly what your home button does.

  • I have Photoshop Elements 12. When I open the program, the tools, menu, everything is teeny tiny. Can barely read it. What's wring and how can I rectify it?

    I have Photoshop Elements 12. When I open the program, the tools, menu, everything is teeny tiny. Can barely read it. What's wring and how can I rectify it?

    lianemily777 a écrit:
    Thanks MichelBParis
    The display resolution allows a user to set according to pixels I think, eg 3200 x 1800. So which setting is considered normal? It does not have a "normal field.
    You are right.
    Before HiDpi displays became available three years ago, you could find advice about what was the good resolution for displays, depending on their size in in/cm and viewing distance.
    - For relatively big displays (22" to 30") a pixel resolution of 1920 x 1200 or 1920 x 1080 was considered optimal.
    - For big laptops or small desktop, 1680 x 1050 or 1640 x 900 were good.
    In Windows, you could set the size of fonts to full resolution or 25% or 50% bigger... if the software supports this feature, which was not the case with Photoshop, Elements... The size of the fonts was deternined and fixed in the software itself, with no way to scale the fonts. The solution needed Microsoft to provide developpers with new programming interfaces and the solution for developpers was to rewrite a substantial part of the code.
    Anyway, to enable good viewing of characters on common 12 or 13" HiDpi displays, you need to use the fonts at 200%.
    And that makes sense. To see the same characters on a 12" display the same as on a 24", they must be twice the size... good rule of thumbs.

  • I bought a song on itunes but it cuts out after 14 seconds on my laptop but on my ipod it plays in full, how can I rectify the tune on my pc, thankyou

    I bought a song on itunes but it cuts out after 14 seconds on my laptop but on my ipod it plays in full, how can I rectify the tune on my pc so that I can play it in the house and put it on a cd for the car. I went into the itunes store to play the tune and it cuts out there too. thankyou

    Hello there, La Clairiere Feerique.
    I understand you are having issues with playback of a purchased song. If iTunes in the Cloud is available in your country, it might be best to delete the song from your computer, then re-download from your purchase history.
    To delete a song the following Knowledge Base article offers how to delete from your iOS device:
    How to delete content you've downloaded from the iTunes Store, App Store, iBooks Store, or Mac App Store
    http://support.apple.com/kb/HT5772
    Music
    Open the section below for the device you are using.
    iPhone, iPad, or iPod touch
    Mac or PC
    Before you delete, find out if you'll be able to download the song you deleted again (it depends on where you live). To delete a song:
    Launch iTunes.
    From the Library pop-up menu, choose Music.
    Click Songs in the navigation bar.
    Click the song you want to delete.
    Press the Delete key on your keyboard.
    In iTunes 11, the album cover art will remain visible, but a cloud icon will appear on it to allow you to download the item again (in countries that support this).
    Note: If you didn't purchase a song from the iTunes Store, you won't be able to download it again for free from iTunes in the Cloud. You might want to back it up somewhere on your computer.
    Afterwards, re-download the purchases from your purchase history:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    http://support.apple.com/kb/HT2519
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • Why Apple can't undo its mistake?

    I wanna point out a big issue with the whole process of two-step verification system. First of all, I need you to know that I was usung my apple id for four years and I spent nearly 400$ on apps and still had 200$ to spend. Moreover, the total value of id was more than that since I had bought many apps on discount. Anyway, 3 days ago I slept and when I woke up, noticed that my id was blocked for security reasons and that I should reset my password. I did what I was told, however, I was required to enter my recovery key. Now, there begins that huge flaw. I've forgotten it (I know it was my responsibility to remember it). When I click on the "Lost your recovery key?" I'm directed to another page on which it says a lost recovery key can be renewed by signing-in to the account and so on. Interestingly, Apple has blocked my id itself so there is no way to sign-in and get a new recovery key. I called Apple support and talked to them for over an hour. They tried various methods. Nothing worked.
    Among things they tried was changing my iforgot.apple.com page in a way to use e-mail authentication or security questions. Unbelievably, the system didn't allow me to use either of options!
    I was furious. I remember that I was just yelling at John (Apple support) who was trying to calm me. After wasting one hour and fifteen minutes this was their solution:
    "Create new account and ,perhaps, don't use two-step verification again."
    The last part hurt the most. I felt dumb. Yes, I was heedless not to properly ssave my recovery key and I accept reprcussions. But, when we hear NSA evesdropping and spying on the Chancellor of Germany, I can't help myself thinking how difficult it can be for Apple to flip the switch and undo what it has done, blocking the account.
    So, I spent the rest of day feeling like you know what. I actually created new account and pirated all Apple Mac applications. I know that my feelings for Apple will not be straight again, and that I'm gouing to jailbreak all iDevices I own to exploit poor developers' hardworking. But, this is Apple who should feel ashamed that made such a cumbersome process that even itself can't or doesn't want to bypass it.
    Here are my suggestions:
    First: after completion of enabling two-step verification, an email is sent. It would be much better to add the recovey key as an attachment to it. My email was the first place that I looked for it.
    Scond: Google's two step verification is more powerful and well-thaought-out. It is bound to your mobile phone and it is much harder to lose your mobile phone than a piece of a paper or a file that your recovery key is on it.
    Third: When I asked Apple the reason that caused blocking my account, they said that some A**H**E attempted many times to sign in to it. So, I don't believe blocking my id was a good deterrant and it did more harm than good. Apple blocked my account to protect me but instead it costed me 600$. It would be better to warn me or ask me to change my password than blocking it.
    And my question is: Why Apple can't unblock my account when I am its legitimate owner. I just don't get it. Shall I pursue justice in court rooms, or will Apple stop being such a mischeavous pestering child who asks for more cash.
    And Steve Jobs said and I quote : "Why join the navy if you can be a pirate?"

    Why Apple can't undo its mistake?
    Whose mistake? The source of the problem:
    I was required to enter my recovery key. Now, there begins that huge flaw. I've forgotten it (I know it was my responsibility to remember it).
    If you had just taken the simple steps of storing your recovery key as Apple tells you to when you set it up, none of this would've happened.
    As it clearly states in the FAQ on 2-step verification: http://support.apple.com/kb/HT5570
    After you turn it on, there will be no way for anyone to access and manage your account at My Apple ID other than by using your password, verification codes sent your trusted devices, or your Recovery Key. You must be responsible for:
    Remembering your password.
    Keeping your trusted devices physically secure.
    Keeping your Recovery Key in a safe place.
    If you lose access to two of these three items at the same time, you could be locked out of your Apple ID account permanently.
    In addition, with two-step verification turned on, only you can reset your password, manage your trusted devices, or create a new recovery key.
    Apple Support can help you with other aspects of your service, but they will not be able to update or recover these three things on your behalf.
    If you aren't responsible enough to do that, you should not have turned the optional security feature on.
    This is your fault, not Apple's.

  • HT4061 Am getting error 3194 unable to use the ipone, how can I rectify this?

    Am getting error 3194 unable to use the ipone, how can I rectify this?

    Unable to contact the iOS software update server gs.apple.com
    Error 1004, 1013, 1638, 3014, 3194: These errors may be the result of the connection to gs.apple.com being redirected or blocked. Follow these steps to resolve these errors:
    Install the latest version of iTunes.
    Check security software. Ensure that communication to gs.apple.com is allowed. Follow this article for assistance with security software. iTunes for Windows: Troubleshooting security software issues.
    Check the hosts file. The restore will fail if there is an active entry to redirect gs.apple.com. Follow iTunes: Advanced iTunes Store troubleshooting to edit the hosts file or revert to a default hosts file. See section "Blocked by configuration: (Mac OS X/Windows) > Rebuild network information".
    Try to restore from another known-good computer and network.
    If the errors persist on another computer, the device may need service.

  • HT1695 Wi Fi option greys out in my new I phone 4s or some times my phone cannot scan for wi fi . How can I rectify it?

    Wi Fi option greys out in my new I phone 4s or some times my phone cannot scan for wi fi . How can I rectify it?

    read http://support.apple.com/kb/ts1559

  • When I instaled new verson my Iphone4 stoped, in the sight shows the Itunes symbol. I tried to connect to Itunes, but can't repair. MISTAKE 3004. What can I do? I'm brasilian and don't speak english very well... Please, help me. Use my e-mail. Junara

    When I instaled new verson my Iphone4 stoped, in the sight shows the Itunes symbol. I tried to connect to Itunes, but can't repair. MISTAKE 3004. What can I do? I'm brasilian and don't speak english very well... Please, help me. Use my e-mail. Junara
    <Personal Information Edited by Host>

    Hello Junara1969,
    Thank you for contacting Apple Support Communirties. I have a couple of articles for you to take a look at to troubleshoot your issue.
    I would start with basic troubleshooting
    Resolve iOS update and restore errors in iTunes
    http://support.apple.com/kb/TS1275
    If you are still having the same issue, then there are further steps for this specific error code here:
    Resolve specific iTunes update and restore errors
    http://support.apple.com/kb/TS3694
    Regards,
    Jeff D.

  • HT201342 I set up my aged fathers iPAD using may account but changed his e-mail account from mine to another I set up for him.Now whenever my sister sends him an e-mail via icloud it appears that it is sent from me.how can I rectify this

    I set up my aged fathers iPAD using may account but changed his e-mail account from mine to another I set up for him.Now whenever my sister sends him an e-mail via icloud it appears that it is sent from me.how can I rectify this

    search google for "iphone remove picture from contact"

  • I cannot reply to emails on my iphone5 I could previously. How can I rectify this?

    I cannot reply to emails on my iphone5. I could do so until a few days ago. How can I rectify this problem?

    Hello there Mahasweta,
    Thank you for using Apple Support Communities!
    I found this article for you when researching why you may not be able to reply or send emails.
    iOS: Unable to send or receive email
    http://support.apple.com/kb/ts3899
    Restart the iOS device.
    Tap Safari and attempt to load a webpage to ensure that the device has Internet access. If you're unable to load a webpage, try the Wi-Fi assistant.
    Try an alternative Internet connection.
    If your email is provided by your Internet provider, try connecting from the home network.
    If your iOS device has an active cellular data plan, try to disable Wi-Fi:  Tap Settings > Wi-Fi and turn off Wi-Fi.
    If not, try a different Wi-Fi network.
    Log in to your email provider's website to ensure that the account is active and the password is correct.
    Delete the account from Settings > Mail, Contacts, Calendars and then add the email account again on the iOS device.
    All the very best,
    Sterling

Maybe you are looking for