Advertisement
vvccs

EXP1

Apr 12th, 2024 (edited)
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. //Program.cs
  2.  
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using Calculation;
  9.  
  10. namespace EXP1
  11. {
  12. class Program
  13. {
  14. static void Main(string[] args)
  15. {
  16. MathLibrary obj = new MathLibrary();
  17. Console.WriteLine("Enter First Number");
  18. int a = Convert.ToInt32(Console.ReadLine());
  19. Console.WriteLine("Enter Second Number");
  20. int b = Convert.ToInt32(Console.ReadLine());
  21.  
  22. float substract = obj.Sub(a, b);
  23. float multiply = obj.Mul(a, b);
  24. float addition = obj.Add(a, b);
  25. float divide = obj.Div(a, b);
  26. float power = obj.Power(a);
  27.  
  28. Console.WriteLine("This Application uses functions from MathLibrary.dll todo simple calculations");
  29. Console.WriteLine("Addition:" + addition);
  30. Console.WriteLine("Substraction:" + substract);
  31. Console.WriteLine("Multilication:" + multiply);
  32. Console.WriteLine("Dividation:" + divide);
  33. Console.WriteLine("Power of a given Number:" + power);
  34.  
  35. Console.ReadLine();
  36.  
  37.  
  38. }
  39. }
  40. }
  41.  
  42.  
  43. //calculation.cs
  44. using System;
  45. using System.Collections.Generic;
  46. using System.Linq;
  47. using System.Text;
  48. using System.Threading.Tasks;
  49.  
  50. namespace Calculation
  51. {
  52. public class MathLibrary
  53. {
  54. public int Add(int a, int b)
  55. {
  56. return a + b;
  57. }
  58. public int Sub(int a, int b)
  59. {
  60. return a - b;
  61. }
  62. public int Div(int a,int b)
  63. {
  64. return a / b;
  65. }
  66. public int Mul(int a,int b)
  67. {
  68. return a * b;
  69. }
  70. public float Power(float a)
  71. {
  72. return a * a;
  73. }
  74. }
  75. }
  76.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement