0% found this document useful (0 votes)
55 views

Dot Net File

The document contains code to convert digits to words in 3 sentences: It takes in a number from the user, stores each digit in an array, then loops through the array backwards printing out the corresponding word for each digit from a predefined array of number words. The document also contains code for currency conversion between rupees, dollars, francs and euros. It uses a menu to select which conversion to perform, takes the amount in rupees from the user, performs the conversion calculation and displays the result. Finally, the document includes a class to convert between Celsius and Fahrenheit temperatures by taking the temperature as input, performing the conversion calculation, and returning the converted temperature.

Uploaded by

Pawan Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views

Dot Net File

The document contains code to convert digits to words in 3 sentences: It takes in a number from the user, stores each digit in an array, then loops through the array backwards printing out the corresponding word for each digit from a predefined array of number words. The document also contains code for currency conversion between rupees, dollars, francs and euros. It uses a menu to select which conversion to perform, takes the amount in rupees from the user, performs the conversion calculation and displays the result. Finally, the document includes a class to convert between Celsius and Fahrenheit temperatures by taking the temperature as input, performing the conversion calculation, and returning the converted temperature.

Uploaded by

Pawan Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Program for convert digit to code

using System;

public class ConvertDigitsToWords


{
public static void Main()
{
int num;
int nextdigit;
int numdigits;
int[] n = new int[20];

string[] digits = { "zero", "one", "two",


"three", "four", "five",
"six", "seven", "eight",
"nine" };

Console.WriteLine("Enter the number");


num = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Number: " + num);
Console.Write("Number in words: ");
nextdigit = 0;
numdigits = 0;
do
{
nextdigit = num % 10;
n[numdigits] = nextdigit;
numdigits++;
num = num / 10;
} while(num > 0);
numdigits--;
for( ; numdigits >= 0; numdigits--)
Console.Write(digits[n[numdigits]] + " ");
Console.WriteLine();
Console.ReadLine();
}
}
Program for currency conversion –rupees to dollar,frank,euro

using System;

class Program
{
static void Main(string[] args)
{
while (true)
{
Console.WriteLine("Enter your Choice : ");
Console.WriteLine("1. Rupees to Franc");
Console.WriteLine("2. Rupees to dollor");
Console.WriteLine("3. Rupees to euro");
Console.WriteLine("4. Exit");
int choice = int.Parse(Console.ReadLine());
switch (choice)
{
case 1:
franc();
break;
case 2:
dollor();
break;
case 3:
euro();
break;
case 4:
break;
default:
Console.WriteLine("Enter valid choice");
break;
}
if (choice == 4)
break;
}
Console.ReadKey();
}
static void franc()
{

Console.WriteLine("Enter amount in Rupees”);


double r = double.Parse(Console.ReadLine());
double f = r / 66.77;
Console.Write("franc :\t{0}\n", f);
}
static void dollor()
{
Console.WriteLine("Enter amount in Rupees:");
double r = double.Parse(Console.ReadLine());
double d = r / 68.06;
Console.Write("dollor :{0}\n", d);
}
static void euro()
{
Console.WriteLine("Enter amount in Rupees:");
double r = double.Parse(Console.ReadLine());
double e = r / 71.38;
Console.Write("euro :\t{0}\n", e);
}
}
Program for convert Celsius to Fahrenheit and Fahrenheit to Celsius .

public static class TemperatureConverter


{
public static double CelsiusToFahrenheit(string temperatureCelsius)
{
// Convert argument to double for calculations.
double celsius = System.Double.Parse(temperatureCelsius);

// Convert Celsius to Fahrenheit.


double fahrenheit = (celsius * 9 / 5) + 32;

return fahrenheit;
}

public static double FahrenheitToCelsius(string temperatureFahrenheit)


{
// Convert argument to double for calculations.
double fahrenheit = System.Double.Parse(temperatureFahrenheit);

// Convert Fahrenheit to Celsius.


double celsius = (fahrenheit - 32) * 5 / 9;

return celsius;
}
}

class TestTemperatureConverter
{
static void Main()
{
System.Console.WriteLine("Please select the convertor direction");
System.Console.WriteLine("1. From Celsius to Fahrenheit.");
System.Console.WriteLine("2. From Fahrenheit to Celsius.");
System.Console.Write(":");

string selection = System.Console.ReadLine();


double F, C = 0;

switch (selection)
{
case "1":
System.Console.Write("Please enter the Celsius temperature: ");
F = TemperatureConverter.CelsiusToFahrenheit(System.Console.ReadLine());
System.Console.WriteLine("Temperature in Fahrenheit: {0:F2}", F);
break;

case "2":
System.Console.Write("Please enter the Fahrenheit temperature: ");
C = TemperatureConverter.FahrenheitToCelsius(System.Console.ReadLine());
System.Console.WriteLine("Temperature in Celsius: {0:F2}", C);
break;

default:
System.Console.WriteLine("Please select a convertor.");
break;
}
}
}

You might also like