Input and Variable problems
The following contains extra input and variable related problems. Try them out.
Problem 1:
What is the best data type to store each of the values below?
The number of people living in Canada
pi to 2 decimal places
The answer to a multiple choice question where the choices are A,B,C or D
pi to 10 decimal places
Number of muffins sold
Taxes due on a bottle of pop
Problem 2:
Write a program that will ask the user to enter the length and width dimensions of a room in meters. Program will then calculate the area of the room (assuming it is rectangular). Remember area is calculated as length*width
Problem 3:
Write a program that will ask the user to enter a decimal number. It will then print out the part of the number before the decimal point and after the decimal point separately.
For example, suppose the user enters 123.456. The program will print out:
the part before the decimal is 123 the part after the decimal is 456
Sample run:
*Note - A sample run is used to provide inside on what you should see when your program runs. You should use it as a guide. It may also serve to clarify the problem.
Problem 4:
Write a program that will ask the user to enter an lower case alphabetic character. The program will then tell them what letter of the alphabet it is.
For example, if the user enters the letter a, the program will say that it is letter number 1. Thus, b would be letter number 2, c would be letter number 3 and so on.
Sample run:
Last updated