Skip to content

Instantly share code, notes, and snippets.

@Sevitte
Created May 25, 2020 19:10
Show Gist options
  • Save Sevitte/356c32d4a98052bc656aee74f3b7cf31 to your computer and use it in GitHub Desktop.
Save Sevitte/356c32d4a98052bc656aee74f3b7cf31 to your computer and use it in GitHub Desktop.
Problem with a variable
using System;
namespace zad_6
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Podaj interwal wysokosci");
double wysokosc = Convert.ToDouble(Console.ReadLine());
double a = 0,b = 0;
if(wysokosc<39000 && wysokosc>34000)
{
//a = (200 - 250) / (39000 - 34000);
a = -0.01;
//a = (Y2 - Y1) / (X2 - X1);
// b= ((-X1) * (Y2 - Y1) - (X2 - X1) * (-Y1)) / (X2 - X1)
b = ((-34000) * (200 - 250) - (39000 - 34000) * (-250)) / (39000 - 34000);
}
if (wysokosc < 34000 && wysokosc > 30000)
{
// a = (300-250) / (34000 - 30000);
a = -0.0125;
b = ((-30000) * (250 - 300) - (34000 - 30000) * (-300)) / (34000 - 30000);
}
if (wysokosc < 30000 && wysokosc > 24000)
{
// a = (400-300) / ( 30000 - 24000);
a = -0.16667;
b = ((-24000) * (300 - 400) - (30000 - 24000) * (-400)) / (30000 - 24000);
}
if (wysokosc < 24000 && wysokosc > 18000)
{
//a = (500-400) / (24000 - 18000 );
a = -0.16667;
b = ((-18000) * (400 - 500) - (24000 - 18000) * (-500)) / (24000 - 18000);
}
if (wysokosc < 18000 && wysokosc > 10000)
{
// a = (700-500) / ( 18000 - 10000 );
a = -0.025;
b = ((-10000) * (500 - 700) - (18000 - 10000) * (-700)) / (18000 - 10000);
}
if (wysokosc < 10000 && wysokosc > 5000)
{
//a = (850 - 700) / (10000 - 5000);
a = -0.03;
b = ((-5000) * (700 - 850) - (10000 - 5000) * (-850)) / (10000 - 5000);
}
if (wysokosc < 5000 && wysokosc > 0)
{
// a = (1013-850) / (5000 - 0);
a = -0.0326;
b = ((-0) * ( 850 - 1013) - (5000 - 0) * (-1013)) / (5000 - 0);
}
double interpolacja;
interpolacja = a * wysokosc + b;
Console.WriteLine("Cisnienie wynosi: " + interpolacja);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment