/* 

  AREA1.C : A C program for calculating areas of
            various shapes.

  Barry McMullin
  25th January 1996.

*/

#include <safe-c.h>

void put_floating_point(floating_point_type number)
{
  string_type s;

  floating_point_to_string(s, number);
  put_string(s);
}

floating_point_type get_floating_point(void)
{
  string_type s;

  get_string(s);
  return (string_to_floating_point(s));
}

void do_square(void)
{
  put_string("do_square(): STUBBED OUT!\n");
}

void do_triangle(void)
{
  floating_point_type height, base;

  put_string("Please enter triangle height; ");
  height = get_floating_point();
  put_string("Please enter triangle base: ");
  base = get_floating_point();

  put_string("The area is: ");
  put_floating_point(0.5 * base * height);
  put_string("\n\n");
}

void main(void)
{
  string_type shape;

  put_string("Welcome to AREA1.\n");

  put_string("Please enter one of the following shapes:\n");
  put_string("  Triangle\n");
  put_string("  Square\n");
  put_string("  Rectangle\n");
  put_string("  Circle\n\n");

  put_string("Shape: ");
  get_string(shape);

  if (string_equal(shape, "Triangle\n"))
    do_triangle();
  else
    if (string_equal(shape, "Square\n"))
      do_square(); 
/*
    else
      if (string_equal(shape, "Rectangle\n"))
        do_rectangle();
      else
        do_circle();
*/

  put_string("\n\nBye from AREA1!\n");
}
