Description
Computer Science
1. Selection Basics 1
Write a program that does the following:
● Ask the user for a number and store it in an integer variable called first
● Ask the user for another number and store it in another integer variable called second
● The program should compare the two numbers
○ If first is greater than second then output “first”
○ If second is greater than first then output “second”
How to test it:
Run the program and enter in the following data:
● first number: 9, second number: 3
● first number: 5, second number: 8
● first number: 5, second number: 5
2. Selection Basics 2
Write a program that does the following:
● Ask the user for a number and store it in an integer variable
● The program should check if the number is between 1000 and 5000
○ If it is then output to the console “Correct!”
○ If it is not then output to the console either “Too big” if greater than 5000 or “Too small” is smaller than 1000
How to test it:
Run the program and enter in the following data:
● 2500
● 666
● 8765
3. [KEY QUESTION] Pizza Pieces
Sometimes it’s important to watch our weight, and that might mean watching how much pizza we eat! We want to be able to enter the size of the pizza and how many slices we ate to work out the volume of pizza consumed.
Inputs will be
● the diameter of pizza in centimetres.
● the total number of slices the pizza was cut into
● the number of slices eaten
Computer Science
Assume that every pizza has a thickness of 2cm, and use the formula for the volume of cylinder to approximate the pizza: volume = pi * radius * radius * height
(you can assume pi is 3.14 or work out how to use pi more accurately in C#!) – Math.PI
What you need to do:
Write a program to help us calculate the amount of pizza eaten based on the information above.
How to test it:
Run the program and enter in the following data:
● diameter: 18cm
● total slices: 8
● slices eaten: 5
Reviews
There are no reviews yet.