CONVERT FOLLOWING CODE FROM PYTHON TO C++
while endProgram == 'no':
pints = [0] * 7
totalPints = 0
averagePints = 0
highPints = 0
lowPints = 0
pints = getPints(pints)
totalPints = getTotal(pints, totalPints)
averagePints = getAverage(totalPints, averagePints)
highPints = getHigh(pints, highPints)
lowPints = getLow(pints, lowPints)
displayInfo(averagePints, highPints, lowPints)
endProgram = raw_input('Do you want to end
while not (endProgram == 'yes' or endProgram == 'no'):
print 'Please enter a yes or no'
endProgram = raw_input('Dp ypu want to end program? (yes or no): ')
def getPints(pints):
counter = 0
while counter < 7:
pints[counter] = input('Enter pints collected: ')
counter = counter + 1
return pints
def getTotal(pints, totalPints):
counter = 0
while counter < 7:
totalPints = totalPints + pints[counter]
counter = counter + 1
return totalPints
def getAverage(totalPints, averagePints):
averagePints = float(totalPints) / 7
return averagePints
def getHigh(pins,highPints):
highPints = pints[0]
counter = 1
while counter < 7:
if pints[counter] > highPints:
highPints = pints[counter]
counter = counter + 1
return highPints
def getLow(pints, lowPints):
lowPints = pints[0]
counter = 1
while counter < 7:
if pints[counter] < lowPints:
lowPints = pints[counter]
counter = counter + 1
return lowPints
def displayInfo(averagePints, highPints, lowPints):
print 'The average number of pints donated is', averagePints
print 'The highest pints donated is', highPints
print 'The lowest pints donated is', lowPints
main()
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 2 images
- In C++, Given the following mystery function, what is the output if the number passed to the function is 7: int mystery(int number) { if (number == 0 || number == 1) return number; else return mystery(number - 1) + mystery(number - 2); }arrow_forwardCan I please get help with this program?arrow_forwardIN RUBY Write a function that returns the distance the snail must travel to the top of the tower given the height and length of each step and the height of the tower. Examples total_distance(0.2, 0.4, 100.0) → 300.0 total_distance(0.3, 0.2, 25.0)→ 41.7 total_distance (0.1, 0.1, 6.0) → 12.0arrow_forward
- Pls make a code for this on c++ and make sure it is 100% correct. i wastred 4 questoins on this and they all are not correct. Write the code as described in the questions below. Submit your code electronically in the box at the bottom. You may only use Java, C# or C++. The economy is defined using a 2-dimensional data structure: A “payday” will be considered to be any region of $ values where all cells in the region are connected either vertically or horizontally. For example, the following illustrates a matrix with 5 rows and 8 columns containing three objects. $’s and P are used in the diagram to represent the two types of values: PPPP$PPPPPP$$PPPPP$$PPP$PP$PPPP$P$PPP$$$ a) Write a program to read in the data from the text file and store it into a data structure. Your program should output it to the screen after it has read in the file. (If you can’t get this to work hard-code the above example and continue to part b). Here is a sample text file (containing the above data):…arrow_forwardThis assignment will give you practice on basic C programming. You will implement a few Cprogramsarrow_forward4- Write a C program to read an integer number num and find it's factorial. Note: the factorial number is all the number multiplied from 1 to the number itself. n! = n(n - 1)(n – 2) ... (2)(1) Example: 5! = (5)(4)(3)(2)(1) = 120arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education