1 /******************************************************************************
2 *
3 * Copyright (C) 2005, The Gentee Group. All rights reserved.
4 * This file is part of the Gentee open source project - http://www.gentee.com.
5 *
6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT").
7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS
8 * ACCEPTANCE OF THE AGREEMENT.
9 *
10 * ID: square 17.10.06 0.0.A.
11 *
12 * Author: Alexey Krivonogov ( gentee )
13 *
14 ******************************************************************************/
15
16 func double rectangle( double x y )
17 {
18 return 2.0 * ( x + y )
19 }
20
21 func double circle( double x )
22 {
23 return 2.0 * 3.1415 * x
24 }
25
26 func main<main>
27 {
28 str input
29 double width height
30
31 while 1
32 {
33 print("Enter the number of the action:
34 1. Calculate the perimeter of a rectangle
35 2. Calculate the perimeter of a circle
36 3. Exit\n")
37 switch getch()
38 {
39 case '1'
40 {
41 print("Specify the width of the rectangle: ")
42 width = double( conread( input ))
43 print("Specify the height of the rectangle: ")
44 height = double( conread( input ))
45 print("The perimeter of the rectangle: \( rectangle( width, height ))\n\n")
46 }
47 case '2'
48 {
49 print("Specify the radius of the circle: ")
50 width = double( conread( input ))
51 print("The perimeter of the circle: \( circle( width ))\n\n")
52 }
53 case '3', 27 : break
54 default : print("You have entered a wrong value!\n\n")
55 }
56 }
57 }
58