I’m studying for my Computer Science class and don’t understand how to answer this. Can you help me study?

Assignment Content

  1. Select ANY 4 (Four), (Four question must be Even or four questions must be Odd) from the enclosed programming projects: Read the enclosed lecture notes and do the following:Must have Docstring and comments similar to the programs we did in class.

    Project 1. Write a program that takes the radius of a sphere (a floating-point number) as input and outputs the sphere’s diameter, circumference, surface area, and volume.

    Project 2. An employee’s total weekly pay equals the hourly wage multiplied by the total number of regular hours plus any overtime pay. Overtime pay equals the total overtime hours multiplied by 1.5 times the hourly wage. Write a program that takes as inputs the hourly wage, total regular hours, and total overtime hours and displays an employee’s total weekly pay.

    Project 3. A standard science experiment is to drop a ball and see how high it bounces. Once the “bounciness” of the ball has been determined, the ratio gives a bounciness index. For example, if a ball dropped from a height of 10 feet bounces 6 feet high, the index is 0.6 and the total distance traveled by the ball is 16 feet after one bounce. If the ball were to continue bouncing, the distance after two bounces would be 10 ft + 6 ft + 6 ft + 3.6 ft = 25.6 ft. Note that distance traveled for each successive bounce is the distance to the floor plus 0.6 of that distance as the ball comes back up. Write a program that lets the user enter the initial height of the ball and the number of times the ball is allowed to continue bouncing. Output should be the total distance traveled by the ball.

    Project 4. The German mathematician Gottfried Leibniz developed the following method to approximate the value of π:π/4 = 1 – 1/3 + 1/5 – 1/7 + …Write a program that allows the user to specify the number of iterations used in this approximation and displays the resulting value.

    Project 5. The TidBit Computer Store has a credit plan for computer purchases. There is a 10% down payment and an annual interest rate of 12%. Monthly payments are 5% of the listed purchase price minus the down payment. Write a program that takes the purchase price as input. The program should display a table, with appropriate headers, of a payment schedule for the lifetime of the loan. Each row of the table should contain the following items:• The month number (beginning with 1)• The current total balance owed• The interest owed for that month• The amount of principal owed for that month• The payment for that month• The balance remaining after paymentThe amount of interest for a month is equal to balance * rate / 12. The amount of principal for a month is equal to the monthly payment minus the interest owed.

    Project 6. The Payroll Department keeps a list of employee information for each pay period in a text file. The format of each line of the file is:<last name> <hourly wage> <hours worked>Write a program that inputs a filename from the user and prints a report to the terminal of the wages paid to the employees for the given period. The report should be in tabular format with the appropriate header. Each line should contain an employee’s name, the hours worked, and the wages paid for that period.

    Project 7. Statisticians would like to have a set of functions to compute the median and mode of a list of numbers. The median is the number that would appear at the midpoint of a list if it were sorted. The mode is the number that appears most frequently in the list. Define these functions in a module named stats.py. Also include a function named mean, which computes the average of a set of numbers. Each function expects a list of numbers as an argument and returns a single number.

    Project 8. Write a program that allows the user to navigate through the lines of text in a file. The program prompts the user for a filename and inputs the lines of text into a list. The program then enters a loop in which it prints the number of lines in the file and prompts the user for a line number. Actual line numbers range from 1 to the number of lines in the file. If the input is 0, the program quits. Otherwise, the program prints the line associated with that number.

    Project 9. In the guess-the-number program discussed in this chapter, the computer thinks of a number and the user inputs guesses, until a correct guess is detected. Write a program in which these roles are reversed: the user thinks of a number and the computer computes and outputs guesses. Like the computer in the earlier version of this game, the user must provide hints, such as “<” and “>” (meaning “my number is smaller” and “my number is larger,” respectively), when the computer guesses incorrectly. The user inputs “=” when the computer guesses correctly. The user should input the lower bound and the upper bound of the range of numbers at startup. The computer should need at most round(log2(high 2 low) 1 1) guessesto get the correct number. Your program should track the number of guesses and output the message “You’re cheating!” if the number of incorrect guesses reaches the maximum needed. Here is a sample interaction with this program:Enter the smaller number: 1Enter the larger number: 100Your number is 50Enter =, <, or >: >Your number is 75Enter =, <, or >: <Your number is 62Enter =, <, or >: <Your number is 56Enter =, <, or >: =Hooray, I’ve got it in 4 tries!

    Project 10. A simple course management system models a student’s information with a name and a set of test scores. This system should be able to create a student object with a given name and a number of scores, all of which will be 0 at startup. The system should be able to access or replace a score at the given position (counting from 0), obtain the number of scores, obtain the highest score, obtain the average score, and obtain the student’s name. In addition, the student object when printed should show the student’s name and scores as in the following example:Name: Ken LambertScore 1: 88Score 2: 77Score 3: 100Define a Student class that supports these features and behavior, and write a short tester function that creates a Student object and runs its methods.

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *