Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
To write a program in C# to perform conversion of dollars to rupees
#1

Aim:
To write a program in C# to perform conversion of dollars to rupees.
Algorithm:
ALGORITHM FOR COMPONENT.
Step 1: Create a namespace as currwithcomp.
Step 2: Create a class called currency as public.
Step 3: Inside the class declare the private variables x of type integer.
Step 4: Define a property variables x.
Step 5: In the property we have the get and set method.
Step 6: Get method is used to get the value form the user and set is used for
setting the user value to the original variables.
Step 7: Define a method called doll() as public.
Step 7.1: Return the value of x * 46.
Step 7.2: End of the method.
Step 8: End of the component.
AGORITHM FOR MAIN.
Step 1: Create a class called curr.
Step 2: Define the main function.
Step 2.1: Create an object ob for currency.
Step 2.2 : Get the value of x using Console.Readline() method.
Step 2.3: Print the converted value using Console.Writeline() method.
Step 2.4: End of the main.
Program:
COMPONENT
Code:
using System;
namespace CompCS
{  
public class Conv
{
  private int i=0,j=45;
  public int varI
  {
  get{return i;}
  set{i=value;}
  }
  public int sum()
  {
  return i*j;
  }
}
}
MAIN
Code:
using System;
using CompCS;

class ConvertComp
{
  public static void Main()
  {
  Conv obj = new Conv();
  Console.WriteLine("Enter the dollar amount u want to convert:");
  int x = int.Parse(Console.ReadLine());
  obj.varI = x;
  Console.WriteLine("Dollar value : {0}",obj.varI);
  Console.WriteLine("Ruppes value : {0}",obj.sum());
  }
}
Execution Steps:
1.Create a dll file for the component
csc /target:library Convert.cs

2.Create an exe file for the main
csc /reference:Convert.dll ConvertComp.cs
3.Run the exe file
ConvertComp
Output:
Enter the dollar amount u want to convert:30
Dollar value : 30
Ruppes value : 1350
CONVERTING THE CURRENCY VALUES USING COM
CODINGS FOR BUSSINESS LAYER

Code:
Public Class Class1
  Public Function cur1(ByVal c1 As String) As String
  cur1 = c1 * 43.44
  MsgBox(cur1)
  End Function
  Public Function cur2(ByVal c2 As String) As String
  cur2 = c2 * 57.105
  MsgBox(cur2)
  End Function
  Public Function cur3(ByVal c3 As String) As String
  cur3 = c3 * 114.73
  MsgBox(cur3)
  End Function
  Public Function cur4(ByVal c4 As String) As String
  cur4 = c4 * 12.024
  MsgBox(cur4)
  End Function
  Public Function cur5(ByVal c5 As String) As String
  cur5 = c5 * 1.6623
  MsgBox(cur5)
  End Function
End Class
CODINGS FOR PRESENTATION LAYER
Public Class Form1
Code:
Dim obj As New classLibrary1.class1
  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
  If (ComboBox1.Text = "Usa Doller") Then
  Dim s = Val(TextBox1.Text)
  obj.cur1(s)
  ElseIf (ComboBox1.Text = "Eurro") Then
  Dim s = Val(TextBox1.Text)
  obj.cur2(s)
  ElseIf (ComboBox1.Text = "Oman Rial") Then
  Dim s = Val(TextBox1.Text)
  obj.cur3(s)
  ElseIf (ComboBox1.Text = "Uae Dirham") Then
  Dim s = Val(TextBox1.Text)
  obj.cur4(s)
  ElseIf (ComboBox1.Text = "Russian Rouble") Then
  Dim s = Val(TextBox1.Text)
  obj.cur5(s)
  End If
  End Sub
  
End Class
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Powered By MyBB, © 2002-2024 iAndrew & Melroy van den Berg.