Newbie needs help to find bug in his first Perl program
Ron Stephens
rdsteph at earthlink.net
Sun Mar 25 23:24:14 EST 2001
Thanks, Richard, you solved my problem, despite my fuzzy question ;-))) and
to the rest of you, yes, I will try to be much more careful and precise from
now on when asking for help! Point acknowledged.
Thanks to all who answered.. By the way , here is a copy of my now debugged
and working program
Richard Bosnjakovic wrote:
> Ron Stephens wrote:
>
> > Can anyone see what is wrong with this? I have several lines like this
> > and they all give me error messages.
>
> *What* error messages? I don't think anyone want to *guess* what kind of
> error messages you get.
>
> There's no format-specifier named "%y".
>
> --
> Rikard Bosnjakovic - http://a214.ryd.student.liu.se/cv/ - ICQ: 1158217
>
> Anyone sending unwanted advertising e-mail to my address will be
> charged $250 for network traffic and computing time. By extracting my
> address from this message or its header, you agree to these terms.
-------------- next part --------------
print "Decision Analysis Beta Test 0.1"
print "To Help You Decide Amongst Various Alternatives"
print "A General Program Requiring User Input"
number = input ("type a numeral from 2 to 5 to indicate how many options do you want to decide amongst and then press enter:")
x = 1
option1 = raw_input ("what is option1:")
x = x + 1
option2 = raw_input ("what is option2:")
x = x + 1
while x:
if x > number: break
option3 = raw_input ("what is option3:")
x = x + 1
if x > number: break
option4 = raw_input ("what is option4:")
x = x + 1
if x > number: break
option5 = raw_input ("what is option5:")
criteria = input ("How many criteria do you want to use for this decision? Type a numeral from 3 to 6 and then press enter")
y = 1
criteria1 = raw_input ("what is criterium1:")
y = y + 1
criteria2 = raw_input ("what is criterium2:")
y = y + 1
while y:
if y > criteria: break
criteria3 = raw_input ("what is criterium3:")
y = y + 1
if y > criteria: break
criteria4 = raw_input ("what is criterium4:")
y = y + 1
if y > criteria: break
criteria5 = raw_input ("what is criterium5:")
y = y + 1
if y > criteria: break
criteria6 = raw_input ("what is criterium6:")
z = 1
print "Of the criteria you have listed, please give each one a rank when prompted, with 1 being the most important criteria, 2 being the second most important, etc. In other words, after being prompted for each ranking criteria, enter a numeral from 1 to x where x is the total number of ranking criteria you are using, and then press enter."
while z:
rank1 = input ("what is the rank for %s " %criteria1)
z = z + 1
rank2 = input ("what is the rank for %s " %criteria2)
z = z + 1
if z > criteria: break
rank3 = input ("what is the rank for %s " %criteria3)
z = z + 1
if z > criteria: break
rank4 = input ("what is the rank for %s " %criteria4)
z = z + 1
if z > criteria: break
rank5 = input ("what is the rank for %s " %criteria5)
z = z + 1
if z > criteria: break
rank6 = input ("what is the rank for %s " %criteria6)
q = 1
while q:
a = 1
while a:
oneone = input ("where does %s rank for %s ?" % (option1, criteria1))
a = a + 1
onetwo = input ("where does %s rank for %s ?" % (option1, criteria2))
a = a + 1
if a > criteria: break
onethree = input ("where does %s rank for %s ?" % (option1, criteria3))
a = a + 1
if a > criteria: break
onefour = input ("where does %s rank for %s ?" % (option1, criteria4))
a = a + 1
if a > criteria: break
onefive = input ("where does %s rank for %s ?" % (option1, criteria5))
a = a + 1
if a > criteria: break
onesix = input ("where does %s rank for %s ?" % (option1, criteria6))
q = q + 1
if q > number: break
b = 1
while b:
twoone = input ("where does %s rank for %s ?" % (option2, criteria1))
b = b + 1
twotwo = input ("where does %s rank for %s ?" % (option2, criteria2))
if b > criteria: break
b = b + 1
twothree = input ("where does %s rank for %s ?" % (option2, criteria3))
b = b + 1
if b > criteria: break
twofour = input ("where does %s rank for %s ?" % (option2, criteria4))
b = b + 1
if b > criteria: break
twofive = input ("where does %s rank for %s ?" % (option2, criteri5))
b = b + 1
if b > criteria: break
twosix = input ("where does %s rank for %s ?" % (option2, criteria6))
b = b + 1
q = q + 1
if q > number: break
c = 1
while c:
threeone = input ("where does %s rank for %s ?" % (option3, criteria1))
c = c + 1
threetwo = input ("where does %s rank for %s ?" % (option3, criteria2))
c = c + 1
if c > criteria: break
threethree = input ("where does %s rank for %s ?" % (option3, criteria3))
c = c + 1
if c > criteria: break
threefour = input ("where does %s rank for %s ?" % (option3, criteria4))
c = c + 1
if c > criteria: break
threefive = input ("where does %s rank for %s ?" % (option3, criteria5))
c = c + 1
if c > criteria: break
threesix = input ("where does %s rank for %s ?" % (option3, criteria6))
q = q + 1
if q > number: break
d = 1
while d:
fourone = input ("where does %s rank for %s ?" % (option4, criteria1))
d = d + 1
fourtwo = input ("where does %s rank for %s ?" % (option4, criteria2))
d = d + 1
if d > criteria: break
fourthree = input ("where does %s rank for %s ?" % (option4, criteria3))
d = d + 1
if d > criteria: break
fourfour = input ("where does %s rank for %s ?" % (option4, criteria4))
d = d + 1
if d > criteria: break
fourfive = input ("where does %s rank for %s ?" % (option4, criteria5))
d = d + 1
if d > criteria: break
foursix = input ("where does %s rank for %s ?" % (option4, criteria6))
q = q + 1
if q > number: break
e = 1
while e:
fiveone = input ("where does %s rank for %s ?" % (option5, criteria1))
e = e + 1
fivetwo = input ("where does %s rank for %s ?" % (option5, criteria2))
e = e + 1
if e > criteria: break
fivethree = input ("where does %s rank for %s ?" % (option5, criteria3))
e = e + 1
if e > criteria: break
fivefour = input ("where does %s rank for %s ?" % (option5, criteria4))
e = e + 1
if e > criteria: break
fivefive = input ("where does %s rank for %s ?" % (option5, criteria5))
e = e + 1
if e > criteria: break
fivesix = input ("where does %s rank for %s ?" % (option5, criteria6))
q = q + 1
if q > number: break
f = 1
while f:
sixone = input ("where does %s rank for %s ?" % (option6, criteria1))
f = f + 1
sixtwo = input ("where does %s rank for %s ?" % (option6, criteria2))
f = f + 1
if f > criteria: break
sixthree = input ("where does %s rank for %s ?" % (option6, criteria3))
f = f + 1
if f > criteria: break
sixfour = input ("where does %s rank for %s ?" % (option6, criteria4))
f = f + 1
if f > criteria: break
sixfive = input ("where does %s rank for %s ?" % (option6, criteria5))
f = f + 1
if f > criteria: break
sixsix = input ("where does %s rank for %s ?" % (option6, criteria6))
if criteria < 4:
onefour = 0
onefive = 0
onesix = 0
twofour = 0
twofive = 0
twosix = 0
threefour = 0
threefive = 0
threesix = 0
fourfour = 0
fourfive = 0
foursix = 0
fivefour = 0
fivefive = 0
fivesix = 0
rank4 = 0
rank5 = 0
rank6 = 0
elif criteria < 5:
onefive = 0
onesix = 0
twofive = 0
twosix = 0
threefive = 0
threesix = 0
fourfive = 0
foursix = 0
fivefive = 0
fivesix = 0
sixfive = 0
sixsix = 0
rank5 = 0
rank6 = 0
elif criteria < six:
onesix = 0
twosix = 0
threesix = 0
foursix = 0
fivesix = 0
sixsix = 0
rank6 = 0
else:
print "These are the scores for each option. The highest score is the best option"
w = 1
while w:
valueoption1 = (oneone)*(7-rank1) + (onetwo)*(7-rank2) + (onethree)*(7-rank3) + (onefour)*(7 - rank4) + (onefive)*(7-rank5) +(onesix)*(7-rank6)
w = w + 1
if w > number: break
valueoption2 = (twoone)*(7-rank1) + (twotwo)*(7-rank2) + (twothree)*(7-rank3) + (twofour)*(7 - rank4) + (twofive)*(7-rank5) +(twosix)*(7-rank6)
w = w + 1
if w > number: break
valueoption3 = (threeone)*(7-rank1) + (threetwo)*(7-rank2) + (threethree)*(7-rank3) + (threefour)*(7 - rank4) + (threefive)*(7-rank5) +(threesix)*(7-rank6)
w = w + 1
if w > number: break
valueoption4 = (fourone)*(7-rank1) + (fourtwo)*(7-rank2) + (fourthree)*(7-rank3) + (fourfour)*(7 - rank4) + (fourfive)*(7-rank5) +(foursix)*(7-rank6)
w = w + 1
if w > number: break
valueoption5 = (fiveone)*(7-rank1) + (fivetwo)*(7-rank2) + (fivethree)*(7-rank3) + (fivefour)*(7 - rank4) + (fivefive)*(7-rank5) +(fivesix)*(7-rank6)
w = w + 1
if w > number: break
valueoption6 = (oneone)*(7-rank1) + (sixtwo)*(7-rank2) + (sixthree)*(7-rank3) + (sixfour)*(7 - rank4) + (sixfive)*(7-rank5) +(sixsix)*(7-rank6)
r = 1
while r:
print "%s is valued at %d" % (option1, valueoption1)
r = r + 1
if r > number: break
print "%s is valued at %d" % (option2, valueoption2)
r = r + 1
if r > number: break
print "%s is valued at %d" % (option3, valueoption3)
r = r + 1
if r > number: break
print "%s is valued at %d" % (option4, valueoption4)
r = r + 1
if r > number: break
print "%s is valued at %d" % (option5, valueoption5)
r = r + 1
if r > number: break
print "%s is valued at %d" % (option6, valueoption6)
r = r + 1
if r > number: break
print "the option with the highest score is the best choice!!!"
print "Thank you for using DecisionAnalysis. Comments and suggestions are welcome and can be addressed to Ron Stephens at rdsteph at earthlink.net"
More information about the Python-list
mailing list