public static string getPlaylistText(FilteredPlaylist playlist, IndexMode indexMode, string levelFormat) { string pageString = getPlaylistPageText(playlist); CalculateResult levels = playlist.Calculate(); string levelList = ""; for (int i = 0; i < Math.Min(levels.allowedList.Count, FilteredPlaylist.pageSize); i++) { var levelIndex = indexMode == IndexMode.Initial ? levels.allowedList[i].index : i; levelList += GeneralUtilities.formatLevelInfoText(levels.allowedList[i].level, levelIndex, levelFormat) + "\n"; } if (pageString != null) { levelList += $"[FFFFFF]Page {pageString}[-]"; } else if (levels.allowedList.Count > FilteredPlaylist.pageSize) { levelList += $"[FFFFFF]and {levels.allowedList.Count - FilteredPlaylist.pageSize} more[-]"; } else { levelList = levelList.Substring(0, levelList.Length - 1); } return(levelList); }
public void TestFifthGreede() { var testLineFunc = new ComponentFunctionVM() { ACoefficient = 5, BCoefficient = 6, CCoefficient = 30000, X = "10", Y = "11", NameFunction = "5-ой степени" }; var resalt = CalculateResult.Result(testLineFunc); Assert.AreEqual(617846, resalt); }
public void TestThirdGreede() { var testLineFunc = new ComponentFunctionVM() { ACoefficient = 5, BCoefficient = 6, CCoefficient = 300, X = "10", Y = "11", NameFunction = "кубическая" }; var resalt = CalculateResult.Result(testLineFunc); Assert.AreEqual(6026, resalt); }
public void TestSecondGreede() { var testLineFunc = new ComponentFunctionVM() { ACoefficient = 5, BCoefficient = 6, CCoefficient = 30, X = "10", Y = "11", NameFunction = "квадратичная" }; var resalt = CalculateResult.Result(testLineFunc); Assert.AreEqual(596, resalt); }
public void TestLineFunc() { var testLineFunc = new ComponentFunctionVM() { ACoefficient = 5, BCoefficient = 6, CCoefficient = 3, X = "10", Y = "11", NameFunction = "линейная" }; var resalt = CalculateResult.Result(testLineFunc); Assert.AreEqual(59, resalt); }
public IActionResult Calculate(CalculateRequest request) { if (!ModelState.IsValid) { return(RedirectToAction("Index")); } // TODO - Support multiple calculation types. var sum = request.FirstNumber + request.SecondNumber; var result = new CalculateResult { Result = sum }; return(View(result)); }
private int calculatePromotion() { int calculateValue = 0; try { int activePromotionId = Convert.ToInt32(cmbActivePromotion.SelectedValue == null ? "0" : cmbActivePromotion.SelectedValue); int skuId = Convert.ToInt32(cmbSKUIDPrice.SelectedValue == null ? "0" : cmbSKUIDPrice.SelectedValue); CalculateResult calculateResult = new CalculateResult(); calculateValue = calculateResult.CalculateFinalResult(skuId, activePromotionId, Convert.ToInt32(txtUnit.Text), SkuIddatapath); } catch (Exception ex) { Logger.WriteException(ex); } return(calculateValue); }
/// <summary> /// A method provides calculated result and formatted expression for given inputExpression. </summary> /// <param name="inputExpression"> A expression which consist of InputElements with IEnumerable interface. </param> /// <param name="expression"> A formatted expression. </param> /// <param name="result"> A formatted calculation result. </param> /// <returns> A result status of equal key execution </returns> private bool GetEqualResult(IEnumerable <InputElement> inputExpression, out FormattedString expression, out FormattedString result) { expression = Calculator.FormatterInstance.GetFormattedExpressionText(inputExpression); result = ""; CalculateResult resCal = Calculator.CalculatorInstance.Equal(inputExpression); if ((resCal is CalculateSuccess) == false) { DisplayError(resCal.Message); return(false); } result = Calculator.FormatterInstance.GetFormattedOutputText(Calculator.CalculatorInstance.Result.ToString()); return(true); }
/// <summary> /// A method provides calculated result and formatted expression for given expression. </summary> /// <param name="inputExpression"> A expression which consist of InputElements with IEnumerable interface. </param> /// <param name="isNeedCheckException"> A flag value indicates error displaying needs if error happen. </param> /// <param name="expression"> A formatted expression. </param> /// <param name="result"> A formatted calculation result. </param> /// <returns> A status of calculation </returns> private bool GetCalculatedResult(IEnumerable <InputElement> inputExpression, bool isNeedCheckException, out FormattedString expression, out FormattedString result) { expression = Calculator.FormatterInstance.GetFormattedExpressionText(inputExpression); result = string.Empty; CalculateResult resCal = Calculator.CalculatorInstance.SetExpression(inputExpression); if ((resCal is CalculateSuccess) == false) { if (isNeedCheckException) { DisplayError(resCal.Message); return(false); } return(true); } result = Calculator.FormatterInstance.GetFormattedOutputText(Calculator.CalculatorInstance.Result.ToString()); return(true); }
private void btnCalcuate_Click(object sender, EventArgs e) { CalculateResult result = new CalculateResult(_raw_data.Courses); result.ShowDialog(); }
public override void use(ClientPlayerInfo p, string message) { Match playlistCmdMatch = Regex.Match(message, @"^(\w+) ?(.*)$"); if (!playlistCmdMatch.Success) { help(p); return; } string uniquePlayerString = GeneralUtilities.getUniquePlayerString(p); string filterCmd = playlistCmdMatch.Groups[1].Value.ToLower(); string filterCmdData = playlistCmdMatch.Groups[2].Value; switch (filterCmd) { default: MessageUtilities.sendMessage(p, $"[A00000]Invalid sub-command `{filterCmd}`[-]"); help(p); break; case "list": { var searchRegex = GeneralUtilities.getSearchRegex(filterCmdData); var results = ""; foreach (KeyValuePair <string, string> pair in savedFilters) { if (Regex.IsMatch(pair.Key, searchRegex, RegexOptions.IgnoreCase)) { results += "\n" + pair.Key; } } if (results.Length == 0) { results = " None"; } MessageUtilities.sendMessage(p, "[FFFFFF]Found:[-]" + results); break; } case "save": { Match nameFilterMatch = Regex.Match(filterCmdData, @"^(.+?)\s+(.*)$"); if (!playlistCmdMatch.Success) { MessageUtilities.sendMessage(p, "[A00000]Bad format for save[-]"); help(p); return; } var saveAt = nameFilterMatch.Groups[1].Value; var saveFilter = nameFilterMatch.Groups[2].Value; if (saveAt == "") { MessageUtilities.sendMessage(p, "[A00000]Name required[-]"); help(p); return; } else if (saveFilter == "") { MessageUtilities.sendMessage(p, "[A00000]Filter required[-]"); help(p); return; } savedFilters[saveAt] = saveFilter; Entry.save(); PlaylistTools.LevelFilters.LevelFilterLast.SetActivePlayer(p); var result = FilteredPlaylist.ParseFiltersFromString(saveFilter); if (!result.value.Any(filter => filter is PlaylistTools.LevelFilters.LevelFilterLast)) { PlaylistTools.LevelFilters.LevelFilterLast.SaveFilter(p, saveFilter); } else { MessageUtilities.sendMessage(p, "[FFA000]The filter -last will always pull from your last-used filter " + "and does not have a consistent value. If you want to save your last used filter, " + "you will need to re-type it."); } MessageUtilities.pushMessageOption(new MessageStateOptionPlayer(p)); GeneralUtilities.sendFailures(result.failures, 4); MessageUtilities.popMessageOptions(); MessageUtilities.sendMessage(p, $"Saved filter to [FFFFFF]{saveAt}[-]:\n[FFFFFF]{saveFilter}[-]"); break; } case "del": { if (filterCmdData == "") { MessageUtilities.sendMessage(p, "[A00000]You must enter a name[-]"); break; } List <string> toDelete; var count = 0; if (deleteConfirmation.TryGetValue(uniquePlayerString, out toDelete)) { if (filterCmdData.ToLower() == "yes") { foreach (string filterName in toDelete) { savedFilters.Remove(filterName); count++; } MessageUtilities.sendMessage(p, $"Deleted {count} filters."); deleteConfirmation.Remove(uniquePlayerString); Entry.save(); break; } else if (filterCmdData.ToLower() == "no") { deleteConfirmation.Remove(uniquePlayerString); MessageUtilities.sendMessage(p, "Cancelled deletion."); break; } } var searchRegex = GeneralUtilities.getSearchRegex(filterCmdData); toDelete = new List <string>(); var results = ""; foreach (KeyValuePair <string, string> pair in savedFilters) { if (Regex.IsMatch(pair.Key, searchRegex, RegexOptions.IgnoreCase)) { toDelete.Add(pair.Key); results += "\n" + pair.Key; count++; } } if (count > 0) { deleteConfirmation[uniquePlayerString] = toDelete; MessageUtilities.sendMessage(p, $"[FFFFFF]Use [A05000]!filter del yes[-] to delete {count} filters:[-] {results}"); } else { MessageUtilities.sendMessage(p, "[A00000]No filters found[-]"); } } break; case "show": { var searchRegex = GeneralUtilities.getSearchRegex(filterCmdData); var results = ""; foreach (KeyValuePair <string, string> pair in savedFilters) { if (Regex.IsMatch(pair.Key, searchRegex, RegexOptions.IgnoreCase)) { results += $"\n{pair.Key}[FFFFFF]:[-] {pair.Value}"; } } if (results.Length == 0) { results = " None"; } MessageUtilities.sendMessage(p, "[FFFFFF]Found:[-]" + results); break; } case "current": { PlaylistCmd playlistCmd = Cmd.all.getCommand <PlaylistCmd>("playlist"); if (!playlistCmd.canUseCurrentPlaylist) { MessageUtilities.sendMessage(p, "Cannot modify current playlist right now."); break; } Console.WriteLine($"Filter txt: {filterCmdData}"); // 1. load current playlist into filter LevelPlaylist currentList = G.Sys.GameManager_.LevelPlaylist_; FilteredPlaylist preFilterer = new FilteredPlaylist(currentList.Playlist_); MessageUtilities.pushMessageOption(new MessageStateOptionPlayer(p)); GeneralUtilities.sendFailures(GeneralUtilities.addFiltersToPlaylist(preFilterer, p, filterCmdData, false), 4); MessageUtilities.popMessageOptions(); // 2. add filter that always allows the current level and helps us find it after calculation. var indexFilter = new ForceCurrentIndexFilter(currentList.Index_); preFilterer.AddFilter(indexFilter); // 3. Calculate filter results. CalculateResult levels = preFilterer.Calculate(); // 4. Update current playlist currentList.Playlist_.Clear(); currentList.Playlist_.AddRange(levels.levelList); // 4. Get current level index, set playlist index to current level index if (indexFilter.level != null) { int index = levels.levelList.IndexOf(indexFilter.level); if (index >= 0) { currentList.SetIndex(index); } else { currentList.SetIndex(0); MessageUtilities.sendMessage(p, "[A05000]Warning: could not find current level in new playlist (2). Reset to beginning.[-]"); } } else { currentList.SetIndex(0); MessageUtilities.sendMessage(p, "[A05000]Warning: could not find current level in new playlist. Reset to beginning.[-]"); } MessageUtilities.sendMessage(p, "Filtered current playlist. Upcoming:"); FilteredPlaylist filterer = new FilteredPlaylist(currentList.Playlist_, -currentList.Index_ - 1); filterer.AddFilter(new LevelFilterAll()); filterer.AddFilter(new LevelFilterIndex(new IntComparison(currentList.Index_, IntComparison.Comparison.Greater))); MessageUtilities.sendMessage(p, GeneralUtilities.getPlaylistText(filterer, GeneralUtilities.IndexMode.Initial, playlistCmd.levelFormat)); break; } case "upcoming": { PlaylistCmd playlistCmd = Cmd.all.getCommand <PlaylistCmd>("playlist"); if (!playlistCmd.canUseCurrentPlaylist) { MessageUtilities.sendMessage(p, "Cannot modify current playlist right now."); break; } // 1. load current playlist into filter LevelPlaylist currentList = G.Sys.GameManager_.LevelPlaylist_; if (currentList.Index_ == currentList.Count_ - 1) { MessageUtilities.sendMessage(p, "Cannot filter upcoming because you are on the last item of the list."); break; } var levelsUpcoming = currentList.Playlist_.GetRange(currentList.Index_ + 1, currentList.Count_ - currentList.Index_ - 1); FilteredPlaylist preFilterer = new FilteredPlaylist(levelsUpcoming); MessageUtilities.pushMessageOption(new MessageStateOptionPlayer(p)); GeneralUtilities.sendFailures(GeneralUtilities.addFiltersToPlaylist(preFilterer, p, filterCmdData, false), 4); MessageUtilities.popMessageOptions(); // 2. Calculate filter results. List <LevelPlaylist.ModeAndLevelInfo> levels = preFilterer.Calculate().levelList; // 3. Update current playlist currentList.Playlist_.RemoveRange(currentList.Index_ + 1, currentList.Count_ - currentList.Index_ - 1); currentList.Playlist_.AddRange(levels); // 4. Print results MessageUtilities.sendMessage(p, "Filtered current playlist. Upcoming:"); FilteredPlaylist filterer = new FilteredPlaylist(currentList.Playlist_, -currentList.Index_ - 1); filterer.AddFilter(new LevelFilterAll()); filterer.AddFilter(new LevelFilterIndex(new IntComparison(currentList.Index_, IntComparison.Comparison.Greater))); MessageUtilities.sendMessage(p, GeneralUtilities.getPlaylistText(filterer, GeneralUtilities.IndexMode.Initial, playlistCmd.levelFormat)); break; } } }
public CalculateResult Sprzedaz_lokalu_mieszkalnego(double cena) { var result = new CalculateResult(); double taksa_notarialna = 0; double wniosek_wieczystoksiegowy = 200; double oplata_za_zlozenie_wniosku_KW = 200; double VAT = 0.23; if (cena <= 3000) { result.PCC = (cena * 0.02 + " zł").ToString(); result.PCC2 = (cena * 0.02).ToString(); result.TaksaNotarialna = 100.ToString(); result.TaksaVAT = (double.Parse(result.TaksaNotarialna) + (double.Parse(result.TaksaNotarialna) * VAT)).ToString(); result.TaksaResult = (result.TaksaVAT + " zł " + "(" + result.TaksaNotarialna + " + 23% VAT)").ToString(); result.KWVAT = (oplata_za_zlozenie_wniosku_KW * VAT).ToString(); result.Suma = (double.Parse(result.KWVAT) + oplata_za_zlozenie_wniosku_KW).ToString(); result.WniosekWieczystoksiegowy = wniosek_wieczystoksiegowy + " zł".ToString(); result.OplataWniosekWieczystoksiegowy = result.Suma + " zł (" + oplata_za_zlozenie_wniosku_KW + " + 23% VAT)"; result.KwotaKoncowa = (double.Parse(result.PCC2) + double.Parse(result.TaksaVAT) + wniosek_wieczystoksiegowy + double.Parse(result.Suma) + " zł").ToString(); } else if (cena >= 3000 && cena <= 10000) { result.PCC = (cena * 0.02 + " zł").ToString(); result.PCC2 = (cena * 0.02).ToString(); result.TaksaNotarialna = (((cena - 3000) * 0.03) + 100).ToString(); result.TaksaVAT = (double.Parse(result.TaksaNotarialna) + double.Parse(result.TaksaNotarialna) * VAT).ToString(); result.TaksaResult = (result.TaksaVAT + " zł " + "(" + result.TaksaNotarialna + " + 23% VAT)").ToString(); result.KWVAT = (oplata_za_zlozenie_wniosku_KW * VAT).ToString(); result.Suma = (double.Parse(result.KWVAT) + oplata_za_zlozenie_wniosku_KW).ToString(); result.WniosekWieczystoksiegowy = wniosek_wieczystoksiegowy + " zł".ToString(); result.OplataWniosekWieczystoksiegowy = result.Suma + " zł (" + oplata_za_zlozenie_wniosku_KW + " + 23% VAT)"; result.KwotaKoncowa = (double.Parse(result.PCC) + double.Parse(result.TaksaVAT) + wniosek_wieczystoksiegowy + double.Parse(result.Suma) + " zł").ToString(); } else if (cena >= 10000 && cena <= 30000) { result.PCC = (cena * 0.02 + " zł").ToString(); result.PCC2 = (cena * 0.02).ToString(); result.TaksaNotarialna = (((cena - 10000) * 0.02) + 310).ToString(); result.TaksaVAT = (double.Parse(result.TaksaNotarialna) + double.Parse(result.TaksaNotarialna) * VAT).ToString(); result.TaksaResult = (result.TaksaVAT + " zł " + "(" + result.TaksaNotarialna + " +23% VAT)").ToString(); result.KWVAT = (oplata_za_zlozenie_wniosku_KW * VAT).ToString(); result.Suma = (double.Parse(result.KWVAT) + oplata_za_zlozenie_wniosku_KW).ToString(); result.WniosekWieczystoksiegowy = wniosek_wieczystoksiegowy + " zł".ToString(); result.OplataWniosekWieczystoksiegowy = result.Suma + " zł (" + oplata_za_zlozenie_wniosku_KW + " + 23% VAT)"; result.KwotaKoncowa = (double.Parse(result.PCC2) + double.Parse(result.TaksaVAT) + wniosek_wieczystoksiegowy + double.Parse(result.Suma) + " zł").ToString(); } else if (cena >= 30000 && cena <= 60000) { result.PCC = (cena * 0.02 + " zł").ToString(); result.PCC2 = (cena * 0.02).ToString(); result.TaksaNotarialna = (((cena - 30000) * 0.01) + 710).ToString(); result.TaksaVAT = (double.Parse(result.TaksaNotarialna) + double.Parse(result.TaksaNotarialna) * VAT).ToString(); result.TaksaResult = (result.TaksaVAT + " zł " + "(" + result.TaksaNotarialna + " +23% VAT)").ToString(); result.KWVAT = (oplata_za_zlozenie_wniosku_KW * VAT).ToString(); result.Suma = (double.Parse(result.KWVAT) + oplata_za_zlozenie_wniosku_KW).ToString(); result.WniosekWieczystoksiegowy = wniosek_wieczystoksiegowy + " zł".ToString(); result.OplataWniosekWieczystoksiegowy = result.Suma + " zł (" + oplata_za_zlozenie_wniosku_KW + " + 23% VAT)"; result.KwotaKoncowa = (double.Parse(result.PCC2) + double.Parse(result.TaksaVAT) + wniosek_wieczystoksiegowy + double.Parse(result.Suma) + " zł").ToString(); } else if (cena >= 60000 && cena <= 1000000) { result.PCC = (cena * 0.02 + " zł").ToString(); result.PCC2 = (cena * 0.02).ToString(); result.TaksaNotarialna = (((cena - 60000) * 0.004) + 1010).ToString(); result.TaksaVAT = (double.Parse(result.TaksaNotarialna) + double.Parse(result.TaksaNotarialna) * VAT).ToString(); result.TaksaResult = (result.TaksaVAT + " zł " + "(" + result.TaksaNotarialna + " +23% VAT)").ToString(); result.KWVAT = (oplata_za_zlozenie_wniosku_KW * VAT).ToString(); result.Suma = (double.Parse(result.KWVAT) + oplata_za_zlozenie_wniosku_KW).ToString(); result.WniosekWieczystoksiegowy = wniosek_wieczystoksiegowy + " zł".ToString(); result.OplataWniosekWieczystoksiegowy = result.Suma + " zł (" + oplata_za_zlozenie_wniosku_KW + " + 23% VAT)"; result.KwotaKoncowa = (double.Parse(result.PCC2) + double.Parse(result.TaksaVAT) + wniosek_wieczystoksiegowy + double.Parse(result.Suma) + " zł").ToString(); } else if (cena >= 1000000 && cena <= 2000000) { result.PCC = (cena * 0.02 + " zł").ToString(); result.PCC2 = (cena * 0.02).ToString(); result.TaksaNotarialna = (((cena - 1000000) * 0.002) + 4770).ToString(); result.TaksaVAT = (double.Parse(result.TaksaNotarialna) + double.Parse(result.TaksaNotarialna) * VAT).ToString(); result.TaksaResult = (result.TaksaVAT + " zł " + "(" + result.TaksaNotarialna + " +23% VAT)").ToString(); result.KWVAT = (oplata_za_zlozenie_wniosku_KW * VAT).ToString(); result.Suma = (double.Parse(result.KWVAT) + oplata_za_zlozenie_wniosku_KW).ToString(); result.WniosekWieczystoksiegowy = wniosek_wieczystoksiegowy + " zł".ToString(); result.OplataWniosekWieczystoksiegowy = result.Suma + " zł (" + oplata_za_zlozenie_wniosku_KW + " + 23% VAT)"; result.KwotaKoncowa = (double.Parse(result.PCC2) + double.Parse(result.TaksaVAT) + wniosek_wieczystoksiegowy + double.Parse(result.Suma) + " zł").ToString(); } else if (cena >= 2000000) { result.PCC = (cena * 0.02 + " zł").ToString(); result.PCC2 = (cena * 0.02).ToString(); result.TaksaNotarialna = (((cena - 2000000) * 0.0025) + 6770).ToString(); if (taksa_notarialna > 10000) { result.TaksaNotarialna = 10000.ToString(); } result.TaksaVAT = (double.Parse(result.TaksaNotarialna) + double.Parse(result.TaksaNotarialna) * VAT).ToString(); result.TaksaResult = (result.TaksaVAT + " zł " + "(" + result.TaksaNotarialna + " +23% VAT)").ToString(); result.KWVAT = (oplata_za_zlozenie_wniosku_KW * VAT).ToString(); result.Suma = (double.Parse(result.KWVAT) + oplata_za_zlozenie_wniosku_KW).ToString(); result.WniosekWieczystoksiegowy = wniosek_wieczystoksiegowy + " zł".ToString(); result.OplataWniosekWieczystoksiegowy = result.Suma + " zł (" + oplata_za_zlozenie_wniosku_KW + " + 23% VAT)"; result.KwotaKoncowa = (double.Parse(result.PCC2) + double.Parse(result.TaksaVAT) + wniosek_wieczystoksiegowy + double.Parse(result.Suma) + " zł").ToString(); } return(result); }
public async Task <ActionResult <CalculateResult> > CalculateFormula(CalculateOverdraftDIParams parameters) { CalculateResult res = await _service.CalculateFormula(parameters); return(Ok(res)); }