Price Change Alert (Homework)
Неще да работи гнидата каквото и да човъркам.. някои има ли идея как да го фикснеме? ^^
using System;
class PriceChangeAlert
{
static void Main(string[] args)
{
//Entry variables
int n = int.Parse(Console.ReadLine());
double granica = double. Parse(Console.ReadLine());
double lastPrice = double.Parse(Console.ReadLine());
//Prices and Price Difference
for (int i = 0; i < n - 1; i++)
{
double currentPrice = double.Parse(Console.ReadLine());
double div = Proxy(lastPrice, currentPrice);
bool isSignificantDifference = IsDifferentCheck(div, granica);
string message = GetPercentageDifference(currentPrice, lastPrice, div, isSignificantDifference);
Console.WriteLine(message);
lastPrice = currentPrice;
}
}
//Difference Check
static bool IsDifferentCheck(double granica, double IsDifferentCheck)
{
if (Math.Abs(granica) >= IsDifferentCheck)
{
return true;
}
return false;
}
//Difference Percentage
static string GetPercentageDifference(double currentPrice, double lastPrice, double difference, bool eitherTrueOrFalse)
{
string priceChange = "";
if (difference == 0)
{
priceChange = string.Format("NO CHANGE: {0}", currentPrice);
}
else if (!eitherTrueOrFalse)
{
priceChange = string.Format("MINOR CHANGE: {0} to {1} ({2:F2}%)", lastPrice, currentPrice, difference);
}
else if (eitherTrueOrFalse && (difference > 0))
{
priceChange = string.Format("PRICE UP: {0} to {1} ({2:F2}%)", lastPrice, currentPrice, difference);
}
else if (eitherTrueOrFalse && (difference < 0))
{
priceChange = string.Format("PRICE DOWN: {0} to {1} ({2:F2}%)", lastPrice, currentPrice, difference);
}
return priceChange;
}
//Dont know what the fuck this is lol
static double Proxy(double lastPrice, double currentPrice)
{
double result = currentPrice - lastPrice;
return result;
}
}