/* Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of JavaLessons.com
This code is for educational purposes only. Use at own risk.*/

1. public class Language 

2.     extends java.applet.Applet 

3.

4.   java.awt.TextArea  ta ; 

5.  

6.   public Language() 

7.   { 

8.     ta = new java.awt.TextArea ( 20, 30 ) ; 

9.  

10.     ta.append ( "======================\n" ) ; 

11.     ta.append ( "Under construction\n" ) ; 

12.     ta.append ( "======================\n" ) ; 

13.   } 

14.  

15.   public void 

16.   doThis () 

17.   { 

18.     ta.append ( "\n======================\n" ) ; 

19.     ta.append ( "The dothis method has started" ) ; 

20.     ta.append ( "\n======================\n" ) ; 

21.  

22.     String str1, str2, strjoined ; 

23.     str1 = "Love"

24.     str2 = "Marriage"

25.  

26.     strjoined = goTogether ( str1, str2 ) ; 

27.     ta.append ( strjoined) ; 

28.     ta.append ( "\n" ) ; 

29.  

30.     strjoined = goTogether ( "horse", "carriage" ) ; 

31.     ta.append ( strjoined) ; 

32.     ta.append ( "\n======================\n" ) ; 

33.  

34.     double result, number; 

35.     int power ; 

36.  

37.     number = 2.0

38.     power = 8

39.  

40.     result = raise ( number, power ) ; 

41.  

42.     ta.append 

43.     ( number + " raised to " + power + " is : " + result ) ; 

44.     ta.append ( "\n" ) ; 

45.  

46.     number = 2.0

47.     power = 16

48.     ta.append 

49.     ( number + " raised to " + power + " is : " 

50.       + raise ( number, power ) ) ; 

51.     ta.append ( "\n======================\n" ) ; 

52.  

53.     int weeks = 52, div = 4

54.  

55.     boolean itIsSo = isDividable ( weeks, div ) ; 

56.  

57.     if ( itIsSo ) 

58.       ta.append ( weeks + " can be divided by " + div ) ; 

59.     else 

60.       ta.append ( weeks + " can NOT be divided by " + div ) ; 

61.     ta.append ( "\n" ) ; 

62.  

63.     weeks = 52

64.     div = 5

65.  

66.     if (   isDividable ( weeks, div )   ) 

67.     { 

68.       ta.append ( weeks + " can be divided by " + div ) ; 

69.     } 

70.     else 

71.     { 

72.       ta.append ( weeks + " can NOT be divided by " + div ) ; 

73.     } 

74.     ta.append ( "\n======================\n" ) ; 

75.   } 

76.  

77.   String 

78.   goTogether ( String s1, String s2 ) 

79.   { 

80.     String res = s1 + " and " + s2 ; 

81.     return res ; 

82.   } 

83.  

84.   double 

85.   raise ( double nr, int pw ) 

86.   { 

87.     if ( pw == 0

88.       return 1.0

89.  

90.     double res ; 

91.     res = nr ; 

92.  

93.     for ( int i = 1; i < pw ; i++ ) 

94.     { 

95.       res = res * nr ; 

96.     } 

97.     return res ; 

98.   } 

99.  

100.   boolean 

101.   isDividable ( int first, int second ) 

102.   { 

103.     int remaining = first % second ; 

104.  

105.     if ( remaining == 0

106.       return true

107.     else return false

108.   } 

109.  

110.   public void 

111.   init () 

112.   { 

113.     add ( ta ) ; 

114.     validate ( ) ; 

115.     ta.append ( "\n======================\n" ) ; 

116.     ta.append ( "In the init method" ) ; 

117.     ta.append ( "\n======================\n" ) ; 

118.     doThis(); 

119.   } 

120.

121.