doubleweatherFactor=(weather.Factor*2+1d)/(settings.DifficultyFactor*2d+1d)/2d;//calculate a scalar for sales between 0.2 and 1.5 based on the weather factor
doublesignFactor=2.5d-((settings.DifficultyFactor+0.1)*2d)/(Signs+1d);//calculate a scalar between 0.3 and (basically) 2.5 based on the amount of signs
doublepriceFactor=3/(GlassPrice/2+1);//calculate a scalar between (basically) 0 and 3 based on the price of lemonades
Sales=(int)Math.Max(Math.Min(weatherFactor*signFactor*priceFactor*Glasses,Glasses),0);//Multiply the factors and sanitize results
Earnings=(int)Math.Floor((double)Sales*GlassPrice);//Convert result to integer