Commputer Science

Assignment
1-1: Simple Algorithms 
Your text defines an algorithm as “a step-by-step problem solving process in which a solution is arrived at in a finite amount of time.”
We encounter algorithms in our daily lives. Below are three real-life tasks that most of us have performed. Write out a series of steps to achieve each task.
1. Boil an egg.
2. Brush your teeth.
3. Ask the user to input a number of inches. Convert the inches into feet and display the results.
1-2: The Pythagorean Theorem
The Pythagorean Theorem states that there is a relationship among the three sides of a right triangle. The hypotenuse (the side opposite the right angle) is equal to the square root of the sum of the squares of the two sides. The Pythagorean Theorem is often written
c = a2 +b2 
where a and b each represent one side of the triangle and c represents the hypotenuse
Your classmate Fred has written an algorithm based on the Pythagorean Theorem. Unfortunately, his algorithm has scrambled. Help Fred by reordering his instructions into a workable solution.
a.Get the length of side 1 and store in a.
b.Display the value stored in c.
c.Calculate the hypotenuse using the formula: c = sqrt (a2 + b2
d.Get the length of side 2 and store in b.
1-3: Ticket Cost
Sam works at a local entertainment venue. The price for a concert ticket is $55.00. The price for a play ticket is $75.00.
Sam has developed an algorithm to determine ticket charge based on the event type. Use Sam’s algorithm to find the results based on different inputs made by the user.
1-4: Decision-based Algorithm
A cell phone company offers a plan with 450 minutes of voice communications at a rate of $35.00/month. Any minutes over 450 are charged at a rate of 0.40 per minute. 
Write an algorithm that allows the user to input the number of minutes a phone customer used during a particular month. The algorithm should determine the monthly charge. (Do not worry about taxes and other cell phone fees.)
1-5: Object-Oriented Programming
An object-oriented programmer views the world in terms of objects, or entities, which must be defined within a program. There are two parts to an object's definition: its attributes (or data) and its operations (the things the object can do or can be done to the object.) 
Write a program for your college bookstore to track textbook inventory. List four or five attributes the program might use to describe the book object. List two or three operations that may apply to the book object. 



 Read less

Answer Detail

Get This Answer

Invite Tutor