Computer Science Java Style
Introduction
Fundamental Notions and First Constructs

Programming Challenge: General Problem Solving

Objectives

  • To provide an opportunity to write some simple Java programs.

  • To engage you in forms of problem solving which feature either problem decomposition and goal directed planning.

  • To provide you an opportunity to get the "prescribed programming procedure" under your skin. (That is, to get the emacs based, two buffer, template (slot and filler) driven, compile, run, transfer-demo routine down to the point where it is virtually automatic for you.)

  • Problems

    1. The Swimming Pool. A 2 foot wide cement walkway surrounds a 30 foot by 22 foot rectangular swimming pool. Write a Java program which computes and prints the area of the walkway.

    2. The Average Capacity of Containters. The average capacity of a set of five containers is 13 liters. A container with a capacity of 7 liters is added to the set of five. What is the average capacity of the set of six containers?

    3. Driving. Most days, Sera drives from home to work, from work to her health club, and from her health club back home. The distance from her home to her work is 22.5 miles. The distance from her work to her health club is 12 miles. The distance from her health club to her home is 16.2 miles. On one particular day, she averages 32 mph on her way to work, 37.5 mph on her way to the health club, and 44.25 mph on her way back home. How much time did Sera spend driving on this particular day?

    4. Concentric Primary Shapes A yellow circular disk is surrounded by a red area which is bounded by a square whose side is double the diameter of the disk. The red area is surrounded by a blue area which is bounded by a circle whose radius is double the side of the square. The radius of the yellow disk is 25. What percent of the colored figure is blue?

    Instructions

    Write four independent Java programs to solve the problems posed above. More specifically, for each problem, write a Java program to solve the problem, run the solution, and record the demo in the prescribed manner. In so doing, you should provide a meaningful name for each item of information given in the problem specification.

    The programs require no input, but each should produce a single numeric answer, reasonably labelled. The following lines are illustrative...

    ? java WalkwayAreaApp
    The area of the walkway is <float> square feet.
    
    ? java AverageCapacityApp
    The average capacity of the six containers is <float> liters.
    
    ? java DrivingApp
    The time Sera spent driving is <float> hours.
    
    ? java ConcentricShapesApp
    <float> percent of the colored figure is blue.
    
    
    For each problem, identify the problem solving strategy (decomposition or goal directed planning) which you believe most clearly reflects the solution captured by your program.

    Craig Graci
    Last modified: Thu Jan 30 13:22:53 EST