Need some advice

I am having some trouble figuring out how to make this pseudo-code more efficient for the subject could someone please help in figuring this out.

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 have done research and what not to see how to make it more efficient but one way was to make it a switch structure so could someone please help me with this in giving me an example of the switch structure or show me how to do it with this?
Last edited on
closed account (o3hC5Di1)
Hi there,

This part of your pseudocode:

Dark3nd wrote:
read Customer_History

if Customer_History = Clean

History = Good

elseif Customer_History = Pending_Balance

History = OK

elseif Customer_History = Defaulted

History = Risky

endif


Could be written with a switch statement as such:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
switch (Customer_History)
{
    case Clean:
        history = good;
        break;

    case pending_balance:
        history = ok;
        break;

    case defaulted:
        history = risky;
        break;
}


For more information on the switch statement, check out: http://cplusplus.com/doc/tutorial/control/#switch

Hope that helps.

All the best,
NwN
Topic archived. No new replies allowed.