176k views
4 votes
Write a program that reads integers start and stop from the user, then calculates and prints the sum of the cubes (=> **3) of each integer ranging from start to stop, inclusive. "Inclusive" means that both the values start and stop are included.

User Geekyaleks
by
7.8k points

1 Answer

4 votes

Answer:

This program is written in python programming language

Comments are used for explanatory purpose;

Take note of indentations(See Attachment)

Program starts here

#Initialize Sum to 0

sum = 0

#Prompt user for start value

start= int(input("Start Value: "))

#Prompt user for stop value

stop= int(input("Stop Value: "))

#Check if start is less than stop

if(start<=stop):

#Iterate from start to stop

for i in range(start, stop+1, 1):

sum+=i**3

else:

print("Start must be less than or equal to Stop")

#Display Result

print("Expected Output: ",sum)

#End of Program

Write a program that reads integers start and stop from the user, then calculates-example-1
User James Thigpen
by
8.2k points