Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h> //header file for math functions
  3. #include<iomanip> //header file for manipulators
  4. #define PI 3.14159265 //defining a constant called pi
  5. using namespace std;
  6.  
  7.  
  8. class mySine {
  9. public:
  10. float x,y;
  11. float sine(float x){
  12. return sin(x*PI/180);
  13. }
  14. };
  15.  
  16.  
  17. int main () {
  18.  
  19. mySine point1;
  20. point1.x = 0;
  21. point1.y = point1.sine(point1.x);
  22. mySine point2;
  23. point2.x = 10;
  24. point2.y = point2.sine(point2.x);
  25. mySine point3;
  26. point3.x = 20;
  27. point3.y = point3.sine(point3.x);
  28. mySine point4;
  29. point4.x = 30;
  30. point4.y = point4.sine(point4.x);
  31. mySine point5;
  32. point5.x = 50;
  33. point5.y = point5.sine(point5.x);
  34. mySine point6;
  35. point6.x = 60;
  36. point6.y = point6.sine(point6.x);
  37. mySine point7;
  38. point7.x = 70;
  39. point7.y = point7.sine(point7.x);
  40. mySine point8;
  41. point8.x = 80;
  42. point8.y = point8.sine(point8.x);
  43. mySine point9;
  44. point9.x = 90;
  45. point9.y = point9.sine(point9.x);
  46. mySine point10;
  47. point10.x = 100;
  48. point10.y = point10.sine(point10.x);
  49. mySine point11;
  50. point11.x = 110;
  51. point11.y = point11.sine(point11.x);
  52. mySine point12;
  53. point12.x = 120;
  54. point12.y = point12.sine(point12.x);
  55. mySine point13;
  56. point13.x = 130;
  57. point13.y = point13.sine(point13.x);
  58. mySine point14;
  59. point14.x = 140;
  60. point14.y = point14.sine(point14.x);
  61. mySine point15;
  62. point15.x = 150;
  63. point15.y = point15.sine(point15.x);
  64. mySine point16;
  65. point16.x = 160;
  66. point16.y = point16.sine(point16.x);
  67. mySine point17;
  68. point17.x = 170;
  69. point17.y = point17.sine(point17.x);
  70. mySine point18;
  71. point18.x = 180;
  72. point18.y = point18.sine(point18.x);
  73. mySine point19;
  74. point19.x = 190;
  75. point19.y = point19.sine(point19.x);
  76. mySine point20;
  77. point20.x = 200;
  78. point20.y = point20.sine(point20.x);
  79. mySine point21;
  80. point21.x = 210;
  81. point21.y = point21.sine(point21.x);
  82. mySine point22;
  83. point22.x = 220;
  84. point22.y = point22.sine(point22.x);
  85. mySine point23;
  86. point23.x = 230;
  87. point23.y = point23.sine(point23.x);
  88. mySine point24;
  89. point24.x = 240;
  90. point24.y = point24.sine(point24.x);
  91. mySine point25;
  92. point25.x = 250;
  93. point25.y = point25.sine(point25.x);
  94. mySine point26;
  95. point26.x = 260;
  96. point26.y = point26.sine(point26.x);
  97. mySine point27;
  98. point27.x = 270;
  99. point27.y = point27.sine(point27.x);
  100. mySine point28;
  101. point28.x = 280;
  102. point28.y = point28.sine(point28.x);
  103. mySine point29;
  104. point29.x = 290;
  105. point29.y = point29.sine(point29.x);
  106. mySine point30;
  107. point30.x = 300;
  108. point30.y = point30.sine(point30.x);
  109. mySine point31;
  110. point31.x = 310;
  111. point31.y = point31.sine(point31.x);
  112. mySine point32;
  113. point32.x = 320;
  114. point32.y = point32.sine(point32.x);
  115. mySine point33;
  116. point33.x = 330;
  117. point33.y = point33.sine(point33.x);
  118. mySine point34;
  119. point34.x = 340;
  120. point34.y = point34.sine(point34.x);
  121. mySine point35;
  122. point35.x = 350;
  123. point35.y = point35.sine(point35.x);
  124. mySine point36;
  125. point36.x = 360;
  126. point36.y = point30.sine(point36.x);
  127. mySine point37[36]={point1,point2,point3,point4,point5,point6,point7,point8,point9,point10,point11,point12,point13,point14,point15,
  128. point16,point17,point18,point19,point20,point21,point22,point23,point24,point25,point26,point27,point28,point29,
  129. point30 ,point31,point32,point33,point34,point35,point36 };
  130.  
  131. cout<<"x"<<setw(20)<<"y=sin(x)"<<endl;
  132. for(int j=0;j<36;j++)
  133. {
  134. cout << point37[j].x<<setw(20)<<point37[j].y<<endl;
  135. }
  136.  
  137.  
  138.  
  139.  
  140.  
  141. cout<<"------------------------------------------------------------------------------------------------------------"<<endl<<endl;
  142. cout<<"sine wave :"<<endl<<endl; //to display sine wave
  143. cout<<1<<endl;
  144. cout<<setw(28)<<right<<"****"<<endl;
  145. cout<<0.8<<setw(19)<<right<<"*"<<setw(8)<<right<<"*"<<endl;
  146. cout<<setw(19)<<right<<"*"<<setw(12)<<right<<"*"<<endl;
  147. cout<<0.6<<setw(14)<<right<<"*"<<setw(15)<<right<<"*"<<endl;
  148. cout<<setw(15)<<right<<"*"<<setw(18)<<right<<"*"<<endl;
  149. cout<<0.4<<setw(10)<<right<<"*"<<setw(21)<<right<<"*"<<endl;
  150. cout<<setw(11)<<right<<"*"<<setw(24)<<right<<"*"<<endl;
  151. cout<<0.2<<setw(6)<<right<<"*"<<setw(27)<<right<<"*"<<endl;
  152. cout<<setw(7)<<right<<"*"<<setw(30)<<right<<"*"<<endl;
  153. cout<<0<<setw(4)<<right<<"*"<<setw(33)<<right<<"*"<<endl;
  154. cout<<setw(39)<<right<<"*"<<setw(22)<<right<<"*"<<endl;
  155. cout<<-0.2<<setw(36)<<right<<"*"<<setw(20)<<right<<"*"<<endl;
  156. cout<<setw(41)<<right<<"*"<<setw(18)<<right<<"*"<<endl;
  157. cout<<-0.4<<setw(38)<<right<<"*"<<setw(16)<<right<<"*"<<endl;
  158. cout<<setw(43)<<right<<"*"<<setw(14)<<right<<"*"<<endl;
  159. cout<<-0.6<<setw(40)<<right<<"*"<<setw(12)<<right<<"*"<<endl;
  160. cout<<setw(45)<<right<<"*"<<setw(10)<<right<<"*"<<endl;
  161. cout<<-0.8<<setw(42)<<right<<"*"<<setw(8)<<right<<"*"<<endl;
  162. cout<<setw(52)<<right<<"****"<<endl;
  163. cout<<-1<<setw(26)<<100<<setw(13)<<200<<setw(17)<<300<<endl;
  164. cout<<endl<<"-------------------------------------------------------------------------------------------------------------"<<endl<<endl;
  165. system("pause");
  166. return 0;
  167. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement