Question: Lab 5 You are to write and execute code for the following problems. When you are done, capture a screenshot of output and turn it

Lab 5 You are to write and execute code for the following problems. When you are done, capture a screenshot of output and turn it in with the source code via Blackboard Calculator Write a program that works like a calculator: it reads operands and operators and performs calculation At the beginning, the calculator reads a value, an operator and another value, e.g. 5 12, and performs the operation. The result of the operation is stored and will be used as an operand of next operation. After each operation, the calculator prints the temporary result. After the calculator exits An example of input: 1+5*3-6- The corresponding output: 18 12 Result is 12 (6 is the result of 1 +5, 18 is the result of 6*3, and 12 is the result of 18- 6) Spacecraft You are to write a program for a spacecraft so that astronauts can control the flight from the keyboard The commands are 4 - turn left, 6-turn right, 8-accelerate, 2 - slow down, 5 - exit. At the beginning, the spacecraft has speed 0 miles per hour and it is positioned directly to Alpha Centauri (the angle 60 degrees). Command 8 increases the speed by 2 miles per hour, command 2 decreases the speed by 2 miles per hours. Command 4 increases the angle by 4 degrees, command 6 decreases the angle by 4 degrees Write a program that reads a command for a spacecraft and prints the current values of the speed and the angle An example of input: 884865 The corresponding output: Speed: 2 mi/h, angle: 60 degrees Speed: 4 mi/h, angle: 60 degrees Speed: 4 mi/h, angle: 64 degrees Speed: 6 mi/h, angle: 64 degrees Speed: 6 mi/h, angle: 60 degrees Exit
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
