Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
March 31st, 2005, 10:44 AM
 pord_80
Contributing User

Join Date: Mar 2005
Posts: 51
Time spent in forums: 1 Day 4 h 30 m 3 sec
Reputation Power: 9
Run...

I wrote this program....
I cannot seem to get the program to tell the user that the running total is now over 50.......

P.S: Total is over 50! You can stop now

pord_80

THE PROGRAM IS >>>>>>>>>>>>

#Count.py
#This program prompts the user to repeatedly input an integer
#between 1 to 5(inclusive) and keeps a running total
#The program then tells the user to stop if the running total
#is over 50.

total = 0
count = 0
integer = "y"
integer = raw_input("Please enter,y to input integer: ")
while integer == "y" or integer !=50:
integer = input("Enter integer between 1 to 5 inclusive :")
print"Runing total is not 50"
total = total + integer
times = count + total
print
if times == 50:
print"Total is over 50! You can stop now."
print"Total was",total,"and the last interger you entered was",count

#2
March 31st, 2005, 11:04 AM
 pylon
Contributing User

Join Date: Nov 2004
Posts: 88
Time spent in forums: 19 h 10 m 49 sec
Reputation Power: 10
You can try something like this:
Code:
```#Count.py
#This program prompts the user to repeatedly input an integer
#between 1 to 5(inclusive) and keeps a running total
#The program then tells the user to stop if the running total
#is over 50.

times=0
total = 0
count = 0
integer = "y"
integer = raw_input("Please enter,y to input integer: ")
while times < 50:
integer = input("Enter integer between 1 to 5 inclusive :")
print"Runing total is not 50"
total = total + integer
times = count + total
print
print"Total is over 50! You can stop now."
print"Total was",total,"and the last interger you entered was"  ,count```

#3
March 31st, 2005, 11:26 AM
 mawe
Contributing User

Join Date: Nov 2004
Posts: 394
Time spent in forums: 1 Day 10 h 6 m 47 sec
Reputation Power: 51
Hi!

Another version:
Code:
```total = 0
integer = 0
while total < 50:
integer = input("Enter integer between 1 and 5: ")
if integer < 1 or integer > 5:
continue
total += integer
print "Total: %i, still under 50" % total
print "Total: %i, last input: %i" % (total,integer)```

Regards, mawe

#4
March 31st, 2005, 12:40 PM
 pord_80
Contributing User

Join Date: Mar 2005
Posts: 51
Time spent in forums: 1 Day 4 h 30 m 3 sec
Reputation Power: 9
Thank you guys..

Thank you guys....
Just a little adjustment and it works perfectly now.....

print"Total is over 50! You can stop now."
print"Total was",total,"and the last interger you entered was" ,integer

 Viewing: Dev Shed Forums > Programming Languages > Python Programming > Run...