Assume a machine during its initial testing phase produces 10 widgets a day. After 10 days of testing (starting on day 11), it begins to run at full speed, producing 40 widgets a day. After 50 days at full speed (days 11-60), it gradually starts becoming less productive, and produces 1 fewer widget per day, (ie. 39 widgets on day 61, etc.) until on day 100 it no longer produces any widgets.

Required:
Write a program that will read in a day number from the keyboard and will report the total number of widgets produced from the initial testing phase up to and including the day entered. For example, entering 3 would report 30 widgets.

Respuesta :

Answer:

Written in Python:

n = int(input("Days: "))

total = 0

for i in range(1,n+1):

     if i <= 10:

           total = total + 10

     elif i <= 60:

           total = total + 40

     elif i <= 99:

           total = total + 100 - i

print(str(total)+ " widgets")

Explanation:

This line prompts user for number of days

n = int(input("Days: "))

This line initializes total widgets to 0

total = 0

The following iteration calculates the widgets based on the given instruction

for i in range(1,n+1):

     if i <= 10: -> When there are less than or equal to 10

           total = total + 10

     elif i <= 60: -> When there are less than or equal to 10

           total = total + 40

     elif i <= 99: -> When there are less than 100 days

           total = total + 100 - i

This line prints the output

print(str(total)+ " widgets")

fichoh

The required program written in python 3 is :

n = int(input('Enter the number of days :' ))

#takes in an input from the user

total = 0

#initialize total to 0

if n <= 10 :

#if statement input is less than or equal to 10

total = 10*n

# set total to 10 multiplied by the input value

elif n<=60 and n>10:

total = (10*10)+(40*(n-10))

else :

t = n - 60

total = (10*10)+(50*40)+(40-t)

print(total)

#output the total value.

  • n = number of days entered by the user, to calculate the total number of widgets available that day.

  • t = number of days beyond 60 days.

  • total = variable which gives the total number of widgets on a certain day. It is initialized as 0.

  • First if statement uses the condition given for the number of widgets produced in the first 10 days.

  • The elif statement gives the condition for days which falls between 11 and 60 (11 and 60 inclusive).

  • else condition gives the total number of widgets for days above 60.

Learn more : https://brainly.com/question/15061375