[Solved] How to add parity bits on c# [closed]

This should do it: Console.WriteLine(“Please enter a 7- bit binary number”); string number = Console.ReadLine(); int count = 0; for(int i = 0; i < number.Length; i++) { if(number[i] == ‘1’) { count++; } } Console.WriteLine(“Your number with parity bit is “+ number + (count % 2).ToString()); I’d imagine this is beyond your current level, … Read more

[Solved] Regular expression to match the string [closed]

Here’s one of many ways to get it: >>> x = r”'”self.unsupported_cmds = [r’\s*clns\s+routing’,””’ >>> print x “self.unsupported_cmds = [r’\s*clns\s+routing’,” >>> import re >>> pattern = re.escape(x) >>> re.match(pattern, x) <_sre.SRE_Match object at 0x7ffca3f66098> >>> print pattern \”self\.unsupported\_cmds\ \=\ \[r\’\\s\*clns\\s\+routing\’\,\” solved Regular expression to match the string [closed]

[Solved] C# Convert currency to string, remove decimal point but keep decimals, prepend 0s to have fixed width

You can use string.Format() with custom format specifiers. See details here. double dollars = 38.50; // your value int temp = (int)(dollars * 100); // multiplication to get an integer string result = string.Format(“{0:000000000}”, temp); // Output: 000003850 1 solved C# Convert currency to string, remove decimal point but keep decimals, prepend 0s to have … Read more

[Solved] Formula to find week numbers from the Total [closed]

You could take a bitwise AND & with the day value and take this day. const days = { Monday: 1, Tuesday: 2, Wednesday: 4, Thursday: 8, Friday: 16, Saturday: 32, Sunday: 64 }, getDays = value => Object.keys(days).filter(day => value & days[day]); console.log(getDays(127)); // All Days console.log(getDays(80)); // Friday, Sunday console.log(getDays(7)); // Monday, Tuesday, … Read more

[Solved] How to read a file word by word? [closed]

Within your while loop instead of immediately printing the character that you read, store the char in a char array. Add an if statement that does a comparison that checks if the read char is a space character. If it is you should print the stored array and set the index of the array back … Read more