A community for students.
Here's the question you clicked on:
 0 viewing
DarkendSinz30
 3 years ago
Anyone good at programming logic?
DarkendSinz30
 3 years ago
Anyone good at programming logic?

This Question is Closed

DarkendSinz30
 3 years ago
Best ResponseYou've already chosen the best response.0hey I need some help if you can

infinity_
 3 years ago
Best ResponseYou've already chosen the best response.1ok.. just show me the assignment..

DarkendSinz30
 3 years ago
Best ResponseYou've already chosen the best response.0start 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.

infinity_
 3 years ago
Best ResponseYou've already chosen the best response.1ehm.. 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.

DarkendSinz30
 3 years ago
Best ResponseYou've already chosen the best response.0okay but how does this make things more efficient for the program? will it allow the process to continue?

kTwitch
 3 years ago
Best ResponseYou've already chosen the best response.0Depending on the language, turning the ifelse structures into switch structures may make the code slightly more efficient.

infinity_
 3 years ago
Best ResponseYou've already chosen the best response.1More 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 historyincome in an array.

DarkendSinz30
 3 years ago
Best ResponseYou've already chosen the best response.0Okay @kTwitch define switch structures a little bit?

DarkendSinz30
 3 years ago
Best ResponseYou've already chosen the best response.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?

kTwitch
 3 years ago
Best ResponseYou've already chosen the best response.0Depends 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 ifelse statements aren't reliant on the previous one being false, if that makes sense.

DarkendSinz30
 3 years ago
Best ResponseYou've already chosen the best response.0okay but how would that work for this program for instance?

infinity_
 3 years ago
Best ResponseYou've already chosen the best response.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

DarkendSinz30
 3 years ago
Best ResponseYou've already chosen the best response.0so 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?

kTwitch
 3 years ago
Best ResponseYou've already chosen the best response.0switch (Customer_History) case Clean: History = Good; etc. I agree with @infinity_ though in that the assignment is a bit vague.

DarkendSinz30
 3 years ago
Best ResponseYou've already chosen the best response.0I am sorry I am lost a little because this is the first time I am taking programming.

kTwitch
 3 years ago
Best ResponseYou've already chosen the best response.0Try this out (Basic little switch course on CodeCademy)  http://www.codecademy.com/courses/conditionalsinjavascript/3#!/exercises/0

DarkendSinz30
 3 years ago
Best ResponseYou've already chosen the best response.0I understand it is vague yes but if I do the switch structure to it that could make it more easier to read right?

DarkendSinz30
 3 years ago
Best ResponseYou've already chosen the best response.0@infinity_ so in this program where would the store go if I was to place it?

infinity_
 3 years ago
Best ResponseYou've already chosen the best response.1i 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

DarkendSinz30
 3 years ago
Best ResponseYou've already chosen the best response.0okay now I am beginning to understand it

DarkendSinz30
 3 years ago
Best ResponseYou've already chosen the best response.0Thank you guys for the help it was greatly appericated
Ask your own question
Sign UpFind 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
 Engagement 19 Mad Hatter
 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.