Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer these with an algorithm and a program. python using functions QUESTION 1. Identical copies of a book are to be packaged for shipping

Please answer these with an algorithm and a program. python using functions

QUESTION 1. Identical copies of a book are to be packaged for shipping in cartons of standard capacity. The user provides the number of books. Each carton can hold 8 books. Only cartons that are completely filled are shipped. Write a program to show how many cartons will be shipped and how many books will be left over. Create an algorithm for a function that given input of the number of cartons and left over books will take care of just displaying the results with output similar to this text on one line: 6 cartons will be shipped and 2 books will remain. Depending on the numbers the message could be: 1 carton will be shipped and 1 book will remain. (The difference in the messages is one of singular and plural number.) Note that the computation of cartons and books will NOT be a part of the function. Assume those are computed already in the main program and are just inputs to the function which only handles displaying the result, i.e., the print statement. (You do not have to create the algorithm for the main program.) Is there any possible value to having a function just for displaying output as in this case? Is there any output from the function back to the main program in this case?

QUESTION 2. UD classifies undergraduate students by credits completed. A student with less than 30 credits is a Freshman. At least 30 credits are required to be a Sophomore, 60 to be a Junior, and 90 to be a Senior. Display the classification based on the number of credits input by the user. The algorithm now should use a function that accepts the number of credits from the main program and returns the classification to the program.

QUESTION 3. Create an algorithm for a program that displays the results of multiplying the numbers in each set of five numbers entered by the user. The user should be able to provide as many sets of five numbers as desired i.e., the user should be asked (and can respond Yes or No) whether another set is to be entered. The program should also display the overall sum total of the results of all the multiplications. The prior algorithm should be restructured so that there is a separate function to handle just the entry of the set of numbers and their multiplication. The prior algorithm should be extended so that the set size is more flexible (i.e., not restricted to five numbers) and is specified by the user. Instead of asking the user whether another set is to be entered, the algorithm should ask how many numbers should be in the set to be multiplied. The user will enter 0 to signal that no more sets of numbers are to be provided.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

What Is A Database And How Do I Use It

Authors: Matt Anniss

1st Edition

1622750799, 978-1622750795

More Books

Students also viewed these Databases questions