programming exercises

Programming Exercises: Variable Assignment

Here are some word problems for students to practice variable and data type assignments.

1. Write a program that declares variables to represent the length and width of a room in feet, and the price of carpentering per square yard in dollars and cents. Assign the value 50 to the length variable and the value 70 to the width variable. Compute and display the cost of carpenting room. There are nine square feet in one square yard. The cost is $20 per square yard.

2. Write a program that contains variables that hold your tuition fee and your book fee. Display the sum of the variables. Your fee should be a whole number.

3. Write a program that declares a minute variable that represents minutes worked on a job and assign a value. Display the value in hours and minutes. For example, 197 minutes becomes 3 hours and 17 minutes.

4. Write a program that declares variables to hold your three Initials. Display the three initials with a period following each one, ex. G.M.D. for (Greg M. Dragic).

Sharing is caring!