Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Calculate Used Unit from Readings
using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { Int64 intCheckDigit = 5; decimal CurrentReding = 99242.00M; decimal LastReading = 102364.88M; string strCheckDigitMaxNumber = ""; for (int i = 1; i <= intCheckDigit; i++) { strCheckDigitMaxNumber += "9"; } string strInput = CurrentReding.ToString(); try { strInput = strInput.TrimStart('0'); if (strInput == "" || strInput == "0" || strInput == null) strInput = "0.00"; } catch { strInput = "0.00"; } int CurrentReding_Digit = Convert.ToInt64(Convert.ToDecimal(strInput)).ToString().Length; strInput = LastReading.ToString(); int LastDegit_Digit = Convert.ToInt64(Convert.ToDecimal(strInput.TrimStart('0'))).ToString().Length; decimal decUsedUnit = 0; if (CurrentReding_Digit != LastDegit_Digit && CurrentReding < LastReading && LastDegit_Digit == intCheckDigit) { decimal decCheckDigitMaxNumber = Convert.ToInt64(strCheckDigitMaxNumber); decimal decMaxDigitRemainingReadingUnit = Convert.ToInt64(strCheckDigitMaxNumber) - LastReading; decUsedUnit = decMaxDigitRemainingReadingUnit + CurrentReding; } else { decUsedUnit = CurrentReding - LastReading; } Console.WriteLine(decUsedUnit); } } }
run
|
edit
|
history
|
help
0
12
Download a UTF-8 text file, and display the contents.
my first
amstrong number
Concurrent bag ex
jjj4
Order of Ops Decimals 5.1 (changed result.ToString(fmt2))
C# Calculator Simple
asxsdxsd
ok