Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

DarkendSinz30

  • 2 years ago

Anyone good at programming logic?

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

    hey I need some help if you can

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

    ok.. just show me the assignment..

  3. DarkendSinz30
    • 2 years ago
    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.

  4. infinity_
    • 2 years ago
    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.

  5. DarkendSinz30
    • 2 years ago
    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?

  6. kTwitch
    • 2 years ago
    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.

  7. infinity_
    • 2 years ago
    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.

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

    Okay @kTwitch define switch structures a little bit?

  9. DarkendSinz30
    • 2 years ago
    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?

  10. kTwitch
    • 2 years ago
    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.

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

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

  12. infinity_
    • 2 years ago
    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

  13. DarkendSinz30
    • 2 years ago
    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?

  14. kTwitch
    • 2 years ago
    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.

  15. DarkendSinz30
    • 2 years ago
    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.

  16. kTwitch
    • 2 years ago
    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

  17. DarkendSinz30
    • 2 years ago
    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?

  18. DarkendSinz30
    • 2 years ago
    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?

  19. infinity_
    • 2 years ago
    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

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

    okay now I am beginning to understand it

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

    Thank you guys for the help it was greatly appericated

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

    Im still n confussed

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

    more details..

  24. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Ask a Question
Find more explanations on OpenStudy

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.