so, in my 50*ish) lines of code for a assignment in my CS104 Course, I am having issues getting specific things to print correctly, there are several things that will not print the way I want.
I would rather add code than change things that are already down, since everything else pretty much works.
Basically the code lets users input numbers between 0-1000 and through while loops and if and else statements
the end result is supposed to print a bit of info, such as:
Smallest Value (Entered)
Largest Value (Entered)
Total of Odd Integers
Total of Even Integers
Maximum Number (Entered)
Minimum Number (Entered)
Cumulative Total (Of All Numbers Entered)
and it only prints the Maximum Number correctly(so far) and the Cumulative. everything else is wrong and I have no clue what to do…
I did email my Prof, but I figured I would ask a wide community for Help.
Only Works with Integers 0 to 1000. No Negatives, we don’t need Negativity Here.
from typing import Any
MaxInteger = 0
MinInteger = 0
tInt = 0
numInt = 0
minInt = 0.0
maxInt = 0.0
oddNum = 0
evenNum = 0
tNum = 0
userInt = float(input(“Enter an Integer or -1 to finish:”))
while nextInt != -1:
sum = str(sum + nextInt)
userInt += 1
maybe Something like ^ would work better below
while userInt >= 0.0:
if userInt >= 1000.0:
MaxInteger = MaxInteger + 1
MinInteger = MinInteger + 1
if userInt < minInt:
minInt = userInt
if userInt > maxInt: maxInt = userInt tInt = tInt + userInt numInt = numInt + 1 while userInt % 2: if userInt > 0: userInt = oddNum else: userInt = evenNum userInt = float(input("Enter an Integer or -1 to finish:"))
if numInt > 0:
average = tInt / numInt
print(“The Smallest Value is:”, MaxInteger)
print(“The Largest Value is:”, MinInteger)
# Both used to have %.2f but RUN would print that in final list.
print(“The Total of Odd Integers is:”, oddNum)
print(“The Total of Even Integers is:”, evenNum)
print(“The Maximum Number is %.2f” % maxInt)
print(“The Minimum Number is %.2f” % minInt)
print(“The Cumulative Total is %.2f” % average)
Ignore some of the # notes, those were for me, incase I needed to add something back, or change something later, or an Idea I had for the code
Thanks for Any help, this is probably some really bad looking code.