Introduction

CONCEPT: In order to be successful in writing programming code it is not only important to know how to code, but what is needed for the code, i.e., variables that will hold the data needed to solve the programming problem and a data type for each variable identified. Additionally, you will need to identify any data that will not change in your program code, this type of data is called a constant.

Variable and Constant Identification Problems

For each of the following problems, identify the required variable(s) by underlining, highlighting, or other means. Write down a name and an appropriate simple data type (e.g., string, number, character, etc.) for each variable you identify.

  1. The West Coast sales unit of a company generates 43 percent of the company’s total sales. Based on this percentage, write a program that will determine how much the West Coast unit will generate if the company has $5.3 million in sales this year.
  2. One acre of land is equivalent to 43,560 square feet. Write a program that calculates the number of acres in a tract of land with a user provided value of square feet.
  3. A bag of cookies holds 26 cookies. The calorie information on the bag claims that there are 10 servings in the bag and that each serving equals 175 calories. Write a program that lets the user enter the number of cookies he or she actually ate and then reports the number of total calories consumed.
  4. Write a program that asks the user to enter three test scores. The program should display each test score, as well as the average test of the scores.
  5. Write a program that asks for the names of three runners and the time, in minutes, it took each of them to finish a race. The program should display the names of the runners in the order that they finished.

Introduction Home

CPSC1012 Home