Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

DarkendSinz30

Anyone good at programming logic?

  • one year ago
  • one year ago

  • This Question is Closed
  1. DarkendSinz30
    Best Response
    You've already chosen the best response.
    Medals 0

    hey I need some help if you can

    • one year ago
  2. infinity_
    Best Response
    You've already chosen the best response.
    Medals 1

    ok.. just show me the assignment..

    • one year ago
  3. DarkendSinz30
    Best Response
    You've already chosen the best response.
    Medals 0

    start read Customer_Name perform Calculate_SafetyLevel() perform Evaluate_History() print Customer_Name print 'Credit History of' Client_Name 'is' History print 'Safety Level of' Client_Name 'is' Safety_Level stop Calculate_SafetyLevel() read Customer_Income if Customer_Income >= $5000 Safety_Level = Excellent elseif Customer_Income >= $3000 Safety_Level = Good elseif Customer_Income >= $1500 Safety_Level = Ok endif return Evaluate_History() read Customer_History if Customer_History = Clean History = Good elseif Customer_History = Pending_Balance History = OK elseif Customer_History = Defaulted History = Risky endif return I need to optimize the above pseudocode to make it more efficient.

    • one year ago
  4. infinity_
    Best Response
    You've already chosen the best response.
    Medals 1

    ehm.. what do you mean more efficient? The code looks optimal for what you want it to do.. Perhaps the one thing you could do is to store the income and the history, so that you can recall them in constant time, instead of the O(something) it would normally take.It's good though to give a description of each procedure, because if (for example) the history and encome is read in constant time, the above "correction" instead of making your code better, would make it use more memory than needed.

    • one year ago
  5. DarkendSinz30
    Best Response
    You've already chosen the best response.
    Medals 0

    okay but how does this make things more efficient for the program? will it allow the process to continue?

    • one year ago
  6. kTwitch
    Best Response
    You've already chosen the best response.
    Medals 0

    Depending on the language, turning the if-else structures into switch structures may make the code slightly more efficient.

    • one year ago
  7. infinity_
    Best Response
    You've already chosen the best response.
    Medals 1

    More efficient means, either that your program runs in less time than it used to, or your program uses less memory than it used to.With my optimization, you just don't need to ask for a users history, or income if you have already stored it.That's why your program runs faster than it used to but uses some more memory in order to store history-income in an array.

    • one year ago
  8. DarkendSinz30
    Best Response
    You've already chosen the best response.
    Medals 0

    Okay @kTwitch define switch structures a little bit?

    • one year ago
  9. DarkendSinz30
    Best Response
    You've already chosen the best response.
    Medals 0

    @infinity that works so if I just replace the() beside history with a store function it should make it more efficient for the program?

    • one year ago
  10. kTwitch
    Best Response
    You've already chosen the best response.
    Medals 0

    Depends on language again, but it's generally in the format - switch (variable) case value: code; break; case value: code; break; etc. There's also sometimes a default case at the bottom. However, you can only use it if the if-else statements aren't reliant on the previous one being false, if that makes sense.

    • one year ago
  11. DarkendSinz30
    Best Response
    You've already chosen the best response.
    Medals 0

    okay but how would that work for this program for instance?

    • one year ago
  12. infinity_
    Best Response
    You've already chosen the best response.
    Medals 1

    @DarkendSinz30 I am just saying that storing stuff in memory could make your program run faster.In my opinion though, the assignment is quite abstract, by saying "make the code more efficient" you could mean anything, you can't possibly know what exactly to correct :P

    • one year ago
  13. DarkendSinz30
    Best Response
    You've already chosen the best response.
    Medals 0

    so wait if I replace the else if with a switch program it would run as if it were switching everything and putting it in a proper order?

    • one year ago
  14. kTwitch
    Best Response
    You've already chosen the best response.
    Medals 0

    switch (Customer_History) case Clean: History = Good; etc. I agree with @infinity_ though in that the assignment is a bit vague.

    • one year ago
  15. DarkendSinz30
    Best Response
    You've already chosen the best response.
    Medals 0

    I am sorry I am lost a little because this is the first time I am taking programming.

    • one year ago
  16. kTwitch
    Best Response
    You've already chosen the best response.
    Medals 0

    Try this out (Basic little switch course on CodeCademy) - http://www.codecademy.com/courses/conditionals-in-javascript/3#!/exercises/0

    • one year ago
  17. DarkendSinz30
    Best Response
    You've already chosen the best response.
    Medals 0

    I understand it is vague yes but if I do the switch structure to it that could make it more easier to read right?

    • one year ago
  18. DarkendSinz30
    Best Response
    You've already chosen the best response.
    Medals 0

    @infinity_ so in this program where would the store go if I was to place it?

    • one year ago
  19. infinity_
    Best Response
    You've already chosen the best response.
    Medals 1

    i mean something like that: read customers history; if(array[history]!=EMPTY) return history.status; else ..... array[history]=customer.history.. or something like that, keep an array of the history so that you can leave the function right away, without keep calculating the same things over and over

    • one year ago
  20. DarkendSinz30
    Best Response
    You've already chosen the best response.
    Medals 0

    okay now I am beginning to understand it

    • one year ago
  21. DarkendSinz30
    Best Response
    You've already chosen the best response.
    Medals 0

    Thank you guys for the help it was greatly appericated

    • one year ago
  22. Kevin0528
    Best Response
    You've already chosen the best response.
    Medals 0

    Im still n confussed

    • one year ago
  23. infinity_
    Best Response
    You've already chosen the best response.
    Medals 1

    more details..

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.