In your algorithms, use indentation to show that a line in the algorithm is inside of a loop or a conditional.
For example:
if x equals y output(x)
The line output(x) only executes if x equals y is true. As a result output(x) is indented under the if statement.
Note:
- Please make sure that what you submit is not code in any language (cpp, python, etc).
Merely produce pseudocode using algorithm rules.
- Examples of good pseudocode are found her e.
- Your work should be typed . Submit your assignment as a PDF to Homewor k 1 on Moodle.
Problem Set
- TheS. Census provides information about the current U.S. population as well as approximate rates of change. Using those rates and the current US population, write an algorithm to calculate the U.S. population in exactly one year (365 days).
Your algorithm should output the result of your calculations. Three rates of change are provided:
- There is a birth every 8 seconds
- There is a death every 12 seconds
- There is a new immigrant every 27 seconds
Current U.S. population: 328,441,687
- A day has 86,400 seconds (246060). Given a number of seconds in the range of 0 to 1,000,000 seconds, output the time as days, hours, minutes, and seconds for a 24 hour clock. For example, 70,000 seconds is 0 days, 19 hours, 26 minutes, and 40 seconds. Your program should have user input that is the number of seconds to convert, and then use that number in your calculations. If your results are W, X, Y, and Z, then your output should be displayed as : The time is W days, X hours, Y minutes, and Z seconds.
- The Zootopia Police Department is recruiting new officers and has come up with an innovative equation to hire. They define hireScore as a weighted sum of agility , strength, and speed . hireScore = 1.8 * agility + 2.16 * strength +24 * speed
The candidate for this hiring season are foxes, bunnies, and sloths. Chief Bogo has requested you to write a program that takes in these attributes and process a higreScore for the candidate.
The program should provide a menu to choose the anthropomorphic animal. The menu should have the following options:
- Fox
- Bunny
- Sloth
- Quit
Once an animal is selected, the program should ask the two of the characteristics based on the animal
- For fox, take input for agility and strength
- For bunny, take input for agility and speed
- For Sloth, take input for strength and speed
Write an algorithm to compute the hireScore based on the inputs using the weighted sum formula. When you compute the hireScore, the third characteristic would be 0. The computed hireScore should be displayed on the screen. The menu will run in a loop, continually offering Bogo four options until he chooses to quit.
- A bank account has an initial deposit of $10,000. Every month $500 is withdrawn to meet college expenses. After the money is withdrawn, an interest is computed at the rate of 6 percent per annum (0.5 percent per month). This interest is compounded monthly. Write an algorithm to find how many years it takes for the account balance to become $0.
Hint: Create a table with money that is getting compounded and the money that is withdrawn and calculate by hand what happens in the first 5 months. Then use the pattern to help you figure out the algorithm.
- Make changes to the algorithm to ask the user to input the values for principal, rate and monthly expenditure. Is there a scenario where the algorithm will not terminate (maybe enter an infinite loop)? If so, make changes to the algorithm so that it always terminates.
- Write an algorithm that will ask the user to enter 10 characters. Letters a, e, i, o, u in the English alphabet are vowels. The algorithm should then count and display the total number of vowels among the 10 characters entered by the user.
- In science, the temperature is always described in Celsius, but in the U.S. we tend to use Fahrenheit. Write an algorithm that takes user input for Fahrenheit and converts it into Celsius. The formula is:
Celsius = 59 (Fahrenheit 32)
- Punith is a student in CSCI 1300 in this semester. Hes writing a program that prints Hello 1300!, but its not working well. Describe two compile-time errors and one run-time error and how to fix them. (The cpp file is available on Moodl e. Try to run it by yourself)
Reviews
There are no reviews yet.