Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

Anyone good at programming logic?

Computer Science
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Join Brainly to access

this expert answer

SIGN UP FOR FREE
hey I need some help if you can
ok.. just show me the assignment..
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.

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

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.
okay but how does this make things more efficient for the program? will it allow the process to continue?
Depending on the language, turning the if-else structures into switch structures may make the code slightly more efficient.
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.
Okay @kTwitch define switch structures a little bit?
@infinity that works so if I just replace the() beside history with a store function it should make it more efficient for the program?
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.
okay but how would that work for this program for instance?
@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
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?
switch (Customer_History) case Clean: History = Good; etc. I agree with @infinity_ though in that the assignment is a bit vague.
I am sorry I am lost a little because this is the first time I am taking programming.
Try this out (Basic little switch course on CodeCademy) - http://www.codecademy.com/courses/conditionals-in-javascript/3#!/exercises/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?
@infinity_ so in this program where would the store go if I was to place it?
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
okay now I am beginning to understand it
Thank you guys for the help it was greatly appericated
Im still n confussed
more details..

Not the answer you are looking for?

Search for more explanations.

Ask your own question