Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C# QUESTION. PLS HELP ME OUT 1. Write a program that converts vlaues to and from

ID: 3606921 • Letter: C

Question

C# QUESTION. PLS HELP ME OUT

1. Write a program that converts vlaues to and from the following units.
     a. temperature celcius and farenheight
     b. distance kilometers and miles
     c. distance centimeters and inches
     d. distance meters and feet
     e. time days and years
     f. mass kilograms and pounds

  

Requirements: The program must meet the following requirements.

1. All business logic must be contained in a class library

2. Solution must include a unit test project
   a. Includes positive unit test(s).
     b. Includes negative unit test(s).
     c. Includes edge case test(s).

2. Solution includes a console program that invokes the class library (20 pts).

3. Solution includes a windows forms program that invokes the class library (50 pts).
     a. Form must have focus on first input field at startup.
     b. Form must include a menu control with File > Exit option including hot key.
     c. Menu control must also have a Clear Form option that clears all input fields on the form.
     d. Form elements must have consistent alignment and sizing.

Explanation / Answer

Steps to create and use a classlibrary in ASP.NET/Visual Studio

Step 1: Start Microsoft Visual Studio

Step 2: On the Menu Bar, click File -> New Project...

Step 3: In the left list, click Windows under Visual C#.

Step 4: In the right list, click ClassLibrary

Step 5: Change the Name to ConversionLibrary and click OK ,Click OK.

Step 6: Change the class name to "Convertor" and copy paste the following code:

//

Your Library Class code:

using System;
using System.Collections.Generic;
using System.Text;
namespace ConversionLibrary
{

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

        // Convert Celsius to Fahrenheit.
        double fahrenheit = (celsius * 9.0 / 5.0) + 32;

        return fahrenheit;
    }

    public 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.0 / 9.0);

        return celsius;
    }


    public double MeterToKilimeter(double meters)

    {

        return meters / 1000;

    }


    public double KilometerToMeter(double kilometers)

    {

        return kilometers * 1000;

    }

    public double InchToCm(double inch)

    {

        return inch / 0.393701;

    }
  
  
    public double CmToInch(double cm)

    {

        return cm * 0.393701;

    }
  
  
    public float MeterToFeet(float meter)

    {

        return meter * 3.280F;

    }
  
  
    public float FeetToMeter(float feet) //correction

    {

        return feet / 3.280F;

    }
  
        
public string DaysToYears(int ndays) {
        int year = ndays / 365;

       int week = (ndays % 365) / 7;

       int days = (ndays % 365) % 7;
    return (year+ "years" + week +"weeks"+ days+"days.");
    }
  
  
    public int YearsToDays(int year)
    {
    return year * 365;
  
  
    }
  
  
    public double PoundToKg(double pound)
    {
    return (pound * 0.4535924);
    }
  
  
  
    public double KgToPound(double kg)
    {
    return (kg / 0.4535924);
    }
  
  
  
  
} //end class


}

---------------------------------------------------------------------End Library-----------------------------------------------------------------------

Step 7: Build the Library: Since you would be creating a library and not an executable, to compile the project:

    On the main menu, you can click Build -> Build ProjectName
    In the Solution Explorer, you can right-click the name of the project and click Build
    In the Class View, you can right-click the name of the project and click Build

Step 8. Create an ASP.NET WebApplication Project : After building the project, you can use it. You can use it in the same project where the library was built or you can use it in another project. If you are working in Microsoft Visual Studio, you can start by creating a new project. To use the library, you would have to reference the library. To do this:


On the Menu bar, you would click Project -> Add Reference or In the Solution Explorer, you would right-click References and click Add Reference..

You can click the Browse tab, locate the folder where the library resides and select it:

Step 9: Call the Library class methods in your application : After selecting the library, you can click OK. You can then use the classes and methods of the library like you would use those of the .NET Framework. Here is your console application:


using System;
using ConversionLibrary;
public class Demo
{
    static void Main()
    {
        Converter conv = new Converter();
        double number1 = 100;
        double number2 = 50;
        double result = conv.CelsiusToFahrenheit(number1);
        Console.WriteLine("CelsiusToFahrenheit"+result);
      
       double result = conv.FahrenheitToCelsius(number1);
        Console.WriteLine("FahrenheitToCelsius"+result);
      
       double result = conv.MeterToKilimeter(number1);
        Console.WriteLine("MeterToKilimeter"+result);
      
       double result = conv.KilometerToMeter(number1);
        Console.WriteLine("KilometerToMeter"+result);
      
       double result = conv.InchToCm(number1);
        Console.WriteLine("InchToCm"+result);
      
       double result = conv.CmToInch(number1);
        Console.WriteLine("CmToInch"+result);
      
       double result = conv.MeterToFeet(number1);
        Console.WriteLine("MeterToFeet"+result);
      
       double result = conv.FeetToMeter(number1);
        Console.WriteLine("FeetToMeter"+result);
      
       double result = conv.DaysToYears(number1);
        Console.WriteLine("DaysToYears"+result);
      
       double result = conv.YearsToDays(number1);
        Console.WriteLine("YearsToDays"+result);
      
       double result = conv.PoundToKg(number1);
        Console.WriteLine("PoundToKg"+result);
      
       double result = conv.KgToPound(number1);
        Console.WriteLine("KgToPound"+result);
    }
}

Step 10: Build and run the project...

For reference : http://www.c-sharpcorner.com/uploadfile/61b832/creating-class-library-in-visual-C-Sharp/

You have to create the form.