jahsexy18
asked on
Pseudocode
I was trying to write a pseudocode abd i was wandering if it was incorrect to do the following
If vacationDays <= 2 then
stay home
Else
if vacationDays >2 and<4 then
Go Nashville
Endif
can I add that additional If
If vacationDays <= 2 then
stay home
Else
if vacationDays >2 and<4 then
Go Nashville
Endif
can I add that additional If
is there any action for vacation >= 4?
if not...u can simply write it as..
If vacationDays <= 2 then
stay home
Else
Go Nashville
Endif
this is not the most correct way, but it will do the same thing as per the first code
:-)
if not...u can simply write it as..
If vacationDays <= 2 then
stay home
Else
Go Nashville
Endif
this is not the most correct way, but it will do the same thing as per the first code
:-)
Forgot to mention you could also have multiple ElseIfs like this
If vacationDays <= 2 then
stay home
Elseif vacationDays >2 and vacationDays<4 then
Go Nashville
Elseif vacationDays >3 and vacationDays<5 then
Go Location2
Elseif vacationDays >4 and vacationDays<6 then
Go Location3
Endif
Also vacationDays >2 and vacationDays<4 is the same as saying vacationDays = 3
Cheers
Scott
If vacationDays <= 2 then
stay home
Elseif vacationDays >2 and vacationDays<4 then
Go Nashville
Elseif vacationDays >3 and vacationDays<5 then
Go Location2
Elseif vacationDays >4 and vacationDays<6 then
Go Location3
Endif
Also vacationDays >2 and vacationDays<4 is the same as saying vacationDays = 3
Cheers
Scott
ASKER
Would it be correct if written like this
If vacationDays <= 2 then
stay home
Elseif vacationDays >2 and vacationDays<4 then
Go Nashville
Endif
Else
If vacationDays >=4 then
Check budget
Endif
If budget >=$1200 then
Go Aruba
Else if budget >$800 then
Go Miami
Else
Go Orlando
End if
If vacationDays <= 2 then
stay home
Elseif vacationDays >2 and vacationDays<4 then
Go Nashville
Endif
Else
If vacationDays >=4 then
Check budget
Endif
If budget >=$1200 then
Go Aruba
Else if budget >$800 then
Go Miami
Else
Go Orlando
End if
Almost it would have to be like this though
If vacationDays <= 2 then
stay home
Elseif vacationDays = 3 then
Go Nashville
Else
Check budget
Endif
If budget >=$1200 then
Go Aruba
Else if budget >$800 then
Go Miami
Else
Go Orlando
End if
Note: vacationDays = 3 is better(more efficient) than vacationDays >2 and vacationDays<4
Also
Else
Check budget
this is better again because in your code it is the same as
ElseIf vacationDays >=4 then
Check budget
HTH
Scott
If vacationDays <= 2 then
stay home
Elseif vacationDays = 3 then
Go Nashville
Else
Check budget
Endif
If budget >=$1200 then
Go Aruba
Else if budget >$800 then
Go Miami
Else
Go Orlando
End if
Note: vacationDays = 3 is better(more efficient) than vacationDays >2 and vacationDays<4
Also
Else
Check budget
this is better again because in your code it is the same as
ElseIf vacationDays >=4 then
Check budget
HTH
Scott
ASKER
Thanks Scott
I am not sure if I am writing discount in the correct way and also the last if ststement with premium customer
If totalAmount <$20 then
Discount=0
Elseif totalAmount >$20 and <$50 then
Discount=5%
Elseif totalAmount >$50 and<$100 then
Discount=10%
Endif
Else
If totalAmount >=$100 and premiumCustomer then
Discount=20%
Else
Discount=15%
I am not sure if I am writing discount in the correct way and also the last if ststement with premium customer
If totalAmount <$20 then
Discount=0
Elseif totalAmount >$20 and <$50 then
Discount=5%
Elseif totalAmount >$50 and<$100 then
Discount=10%
Endif
Else
If totalAmount >=$100 and premiumCustomer then
Discount=20%
Else
Discount=15%
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks scott I rally learned alot from you and I clearly understand now
Glad to help and thanks for the grade
Cheers
Scott
Cheers
Scott
yeah you can add the additional if but it would be as an ElseIf
Also you would need to specify vacationDays in the second clause of the ElseIf like so
If vacationDays <= 2 then
stay home
Elseif vacationDays >2 and vacationDays<4 then
Go Nashville
Endif
You could also have a final Else statement after the ElseIf which would catch any vacationDays that didnt match any of the other expressions
HTH but if you need any more explanation just let me know
Cheers
Scott