Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

B 1 0 0 / I 1 0 1 online , Homework # 2 Due 1 3 1 ? 2 4 Algorithm Examples - Solutions

B100/I101
online , Homework #2
Due 131?24
Algorithm Examples - Solutions
Write an algorithm for the following problems: (You do not need to write a program for these problems yet). The algorithm can just be hand written, but make sure it is readable and if multiple pages make sure staple them all together and name on first page. Make sure to do the three step analysis for each one before you write the algorithm. For full credit you need to turn this in as well. (see how to submit homework below)
We want to know how many cubic feet, or the volume, are in a rectangular solid of a given Height, Width, and Length. (Hint, the Height, Width and Length are inputs to problem, and the cubic foot is the output, and number of cubic feet is equal to Length times Width times Height )
User enters an integer and problem tells user if the number is between 1 and 100, and if is then display "Good Input", else displays "Bad Input".
A problem that will convert a total number of days into the corresponding number of years and days left over. For example, if you enter 1254 days, then it would display "3 years and 159 days". (Hint, there are 365 days in one year, and use the /(div) and %(mod) operators)
A problem that determines if an entered number is negative or positive, and continues to have user enter numbers and display appropriate response until user enters a zero. Will keep looping until the user enters 0.
A problem that has user continue to enter weight of people and keeps a running total weight of all the people and also keeps track of the number of people entered. This will continue until a weight entered is less than or equal to zero. Problem will then display the average weight of all the people.
A child's parents promise to give the child $10 on her twelfth birthday and double the gift on every subsequent birthday until the gift exceeds $1000. Write an algorithm to determine how old the girl will be when the last amount is given and what is that exact amount, and the total amount she would have received including the last gift, through all those years.
An algorithm to read numbers entered by user and displays the sum. Input ends when negative number is entered. The negative number is not included in the sum.
write "This problem adds numbers that you enter"
Sum =0
write "Enter number, negative to quit"
read N
while )(0 do
Sum = Sum +N
write "Enter number, negative to quit"
read N
end while
write "The sum of entered numbers is ", Sum
An algorithm that determines if an entered year is a leap year or not, and then displays whether the year is a leap year or not. Simple formula to determine if year is leap year is if it is evenly divisible by 4.
write "Enter a year to determine if a leap year or not"
read Year
LeapYear = Year mod 4
if Leap Year =0 then
write Year, "is a leap year"
else
write Year, "is not a leap year"
end if
An algorithm that reads a series of positive numbers and keeps track of the smallest and largest numbered entered. Input terminates when the user enters a negative number, then the smallest and largest number is displayed. Negative is not counted as smallest.
write "Enter a series of positive numbers to determine the smallest and largest"
write "Enter first number, negative to quit"
read Number
Largest =0
Smallest = Number
while ( Number 0) do
if (Number > Largest) then
Largest = Number
end if
if (Number Smallest) then
Smallest = Number
end if
write "Enter next number, negative to quit"
read Number
end while
if Largest >0 then
write "The smallest number is ", Smallest
write "The largest number is ", Largest
end if
image text in transcribed

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

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

Where do you see yourself in 10 years?

Answered: 1 week ago