M
Metaconta
Guest
Hi:
I want to do exactly this same code in F #.
Just transform from C# to F# from the code below.
using System;
namespace Calculo_agua_sencillo_consola_INGLES_01_cs
{
class Program
{
static void Main(string[] args)
{
// Show window title.
Console.Title = "Calculation liters of water";
// Window size. 55 X and 16Y.
Console.SetWindowSize(55, 16);
#region Variables.
// Variables.
const double Pi = 3.14;
double radio = 0;
double altura = 0;
double volumen = 0;
double litros = 0;
double nivelAgua = 0;
double resultadoPorcentaje = 0;
double resultadoLitros = 0;
double volumenLitros = 0;
double mitadBarra = 0;
int cantidadTubos = 0;
double cantidadTubosLitros = 0;
double totalLitros = 0;
#endregion
do
{
#region Entering data on the screen.
// Clean screen.
Console.Clear();
// Visible cursor.
Console.CursorVisible = true;
// Data entry.
Console.Write("Enter the radius in m.: ");
radio = double.Parse(Console.ReadLine());
Console.Write("Enter the height in m.: ");
altura = double.Parse(Console.ReadLine());
Console.Write("Enter the height of the water. Maximum is {0}: ", altura);
nivelAgua = double.Parse(Console.ReadLine());
Console.Write("Enter quantity of tubes: ");
cantidadTubos = int.Parse(Console.ReadLine());
#endregion
#region Calculations
// Volume calculation.
volumen = Pi * (radio * radio) * altura;
// Calculation liters.
litros = volumen * 1000;
// Percentage calculation in % of the liter of water.
resultadoPorcentaje = nivelAgua * (100.00 / altura);
// Calculation liters of water.
volumenLitros = Pi * (radio * radio) * nivelAgua;
resultadoLitros = volumenLitros * 1000;
// Calculation liters per quantity of tubes.
cantidadTubosLitros = cantidadTubos * resultadoLitros;
// Calculation of the number of liters with total tubes.
totalLitros = litros * cantidadTubos;
#endregion
#region Drawn progress bar.
// Drawing of the bar.
Console.WriteLine();
Console.WriteLine("0 % 50 % 100 %");
Console.WriteLine("┌────────────────────────┬───────────────────────┐");
Console.ForegroundColor = ConsoleColor.Yellow;
// Half the bar so it is not too big on the screen.
mitadBarra = resultadoPorcentaje / 2;
if (mitadBarra > 50)
{
mitadBarra = 50;
}
// Fill the bar.
for (int i = 1; i <= mitadBarra; i++)
{
Console.Write("█");
}
// If it reaches 100, the # turns red.
if (resultadoPorcentaje > 100)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("#");
}
#endregion
#region Show texts on screen.
// Position of the text to display.
Console.SetCursorPosition(0, 9);
// Shows percentage of deposit.
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write("\nPercentage: " + resultadoPorcentaje.ToString("N2") + " %.");
// Shows how much water is currently present and the total.
Console.Write("\nLiters of water: " + resultadoLitros.ToString("N2") + " / " + litros + " L. total of one tube.");
// Number of tubes not including the connected base, only separate tubes.
Console.Write("\nTotal amount of liters per " + cantidadTubos + " tubes: " +
cantidadTubosLitros.ToString("N2") + " / " + totalLitros.ToString("N2") + " L.");
#endregion
// Invisible cursor.
Console.CursorVisible = false;
// Press any key to continue.
Console.ReadKey();
} while (true);
}
}
}
Electrónica PIC
Continue reading...
I want to do exactly this same code in F #.
Just transform from C# to F# from the code below.
using System;
namespace Calculo_agua_sencillo_consola_INGLES_01_cs
{
class Program
{
static void Main(string[] args)
{
// Show window title.
Console.Title = "Calculation liters of water";
// Window size. 55 X and 16Y.
Console.SetWindowSize(55, 16);
#region Variables.
// Variables.
const double Pi = 3.14;
double radio = 0;
double altura = 0;
double volumen = 0;
double litros = 0;
double nivelAgua = 0;
double resultadoPorcentaje = 0;
double resultadoLitros = 0;
double volumenLitros = 0;
double mitadBarra = 0;
int cantidadTubos = 0;
double cantidadTubosLitros = 0;
double totalLitros = 0;
#endregion
do
{
#region Entering data on the screen.
// Clean screen.
Console.Clear();
// Visible cursor.
Console.CursorVisible = true;
// Data entry.
Console.Write("Enter the radius in m.: ");
radio = double.Parse(Console.ReadLine());
Console.Write("Enter the height in m.: ");
altura = double.Parse(Console.ReadLine());
Console.Write("Enter the height of the water. Maximum is {0}: ", altura);
nivelAgua = double.Parse(Console.ReadLine());
Console.Write("Enter quantity of tubes: ");
cantidadTubos = int.Parse(Console.ReadLine());
#endregion
#region Calculations
// Volume calculation.
volumen = Pi * (radio * radio) * altura;
// Calculation liters.
litros = volumen * 1000;
// Percentage calculation in % of the liter of water.
resultadoPorcentaje = nivelAgua * (100.00 / altura);
// Calculation liters of water.
volumenLitros = Pi * (radio * radio) * nivelAgua;
resultadoLitros = volumenLitros * 1000;
// Calculation liters per quantity of tubes.
cantidadTubosLitros = cantidadTubos * resultadoLitros;
// Calculation of the number of liters with total tubes.
totalLitros = litros * cantidadTubos;
#endregion
#region Drawn progress bar.
// Drawing of the bar.
Console.WriteLine();
Console.WriteLine("0 % 50 % 100 %");
Console.WriteLine("┌────────────────────────┬───────────────────────┐");
Console.ForegroundColor = ConsoleColor.Yellow;
// Half the bar so it is not too big on the screen.
mitadBarra = resultadoPorcentaje / 2;
if (mitadBarra > 50)
{
mitadBarra = 50;
}
// Fill the bar.
for (int i = 1; i <= mitadBarra; i++)
{
Console.Write("█");
}
// If it reaches 100, the # turns red.
if (resultadoPorcentaje > 100)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("#");
}
#endregion
#region Show texts on screen.
// Position of the text to display.
Console.SetCursorPosition(0, 9);
// Shows percentage of deposit.
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write("\nPercentage: " + resultadoPorcentaje.ToString("N2") + " %.");
// Shows how much water is currently present and the total.
Console.Write("\nLiters of water: " + resultadoLitros.ToString("N2") + " / " + litros + " L. total of one tube.");
// Number of tubes not including the connected base, only separate tubes.
Console.Write("\nTotal amount of liters per " + cantidadTubos + " tubes: " +
cantidadTubosLitros.ToString("N2") + " / " + totalLitros.ToString("N2") + " L.");
#endregion
// Invisible cursor.
Console.CursorVisible = false;
// Press any key to continue.
Console.ReadKey();
} while (true);
}
}
}
Electrónica PIC
Continue reading...