Design an algorithm to prepare a pizza from scratch. Define the ingredients, what will be the flavor and the preparation. Flavor: Pepperoni pizza.
Ingredients:
- Pizza dough.
- Pizza sauce:
- Tomato sauce.
- Kosher salt.
- Ground black pepper.
- Granulated garlic.
- Granulated onion.
- Red bell pepper flakes.
- Olive oil.
- Pepperoni.
- Shredded mozzarella cheese.
- Fresh oregano (optional).
- Flour.
Preparation:
- Procurement of ingredients.
- Preheat the oven.
- Prepare the sauce.
- Roll out the dough.
- Add the ingredients.
- Cooking pizza.
- Cut and serve (optional: add oregano).
Description
Define an algorithm that is able to convert temperatures from Celsius to Fahrenheit and vice versa.
- Obtain the temperature value to be converted.
- If the temperature value is in degrees Fahrenheit, then use Formula A.
- Else (if in degrees Celcius) use Formula B.
A. Formula to convert from degrees Fahrenheit to degrees Celsius:
- I calculate C=(F-32)*5/9 where F is the temperature in degrees Fahrenheit.
- The final result C is the temperature in degrees Celcius.
B. Formula to convert from degrees Celsius to degrees Fahrenheit:
- I calculate F=(C*9/5)+32 where C is the temperature in degrees Celcius.
- The final result F is the temperature in degrees Fahrenheit.
Description
Design an algorithm to calculate the volume of a pyramid, a cube and a sphere.
- Knowing the body for which to calculate the volume
- If the body is a pyramid, then use Formula A.
- Else (if it is a cube) use Formula B.
- Else (if it is a sphere) use Formula C.
A. Formula to calculate the volume of a pyramid:
- I calculate V=1/3*b*a*h where b is the length of the base, a is the width of the base, and h is the height of the pyramid.
- The final result V is the volume of the pyramid.
B. Formula to calculate the volume of a cube:
- I calculate V=l^3 where l is the length of an edge of the base of the cube.
- The final result V is the volume of the cube.
C. Formula to calculate the volume of a sphere:
- I calculate V=4/3*π*r^3 where r is the radius of the sphere and π is the number pi.
- The final result V is the volume of the sphere.
Design an algorithm to check if a number is even or odd. If it is even, write that it is even, otherwise write that it is odd. Represent the algorithm in a flowchart.
Description
Write pseudocode for an algorithm that calculates the age of a person based on date of birth.
- PROGRAM How old are you;
- BEGIN
- OUTPUT("What's your date of birth?");
- INPUT(date of birth);
- SAVE date of birth -> date_of_birth;
- DEFINE current year -> rigth_now;
- DEFINE age -> age;
- RESULT age=rigth_now-date_of_birth;
- OUTPUT("is" + age + "years old");
- END.
Description
We are in a room with three chests. We know that at least one has a treasure in it. Each chest has a message, but all the messages are lies.
Left chest: The middle chest has a treasure
Middle chest: All these chests have treasures in them
Right chest: Only one of these chests has treasures.
Which chests have treasures?
- Since all messages are lies, let's change them to truth:
- Left chest: The middle chest has no treasure.
- Middle chest: No all chests have treasures on them.
- Right chest: It's not possible for Only one of the chests to have a treasure.
- With the above analysis we have two options:
- A. None of the chests has a treasure.
- B. The chests on the left and right have treasure.
- We know that at least one chest has a treasure, so the only congruent option is that the left and right chests have a treasure.
- Answer: Chests A and C have treasures.
