executing a STRING formula???
-
Hi... currently i m using asp.net 2.0 (With C#) i m having an formula in my string as "(((5+6+4)/15)*100))" i would like to execute this string and get the resultant as integer. Help me ... - Karan
-
Hi... currently i m using asp.net 2.0 (With C#) i m having an formula in my string as "(((5+6+4)/15)*100))" i would like to execute this string and get the resultant as integer. Help me ... - Karan
first convert the string into integer by Convert.ToInt32 then perform calculations
-
first convert the string into integer by Convert.ToInt32 then perform calculations
11Developer wrote:
first convert the string into integer by Convert.ToInt32 then perform calculations
How will you convert this string "
(((5+6+4)/15)*100))
" as interger ? Did you check the answer of J4amieC ?Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Visit My Latest Article : Beginner's Guide : Exploring IIS 6.0 With ASP.NET
-
11Developer wrote:
first convert the string into integer by Convert.ToInt32 then perform calculations
How will you convert this string "
(((5+6+4)/15)*100))
" as interger ? Did you check the answer of J4amieC ?Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Visit My Latest Article : Beginner's Guide : Exploring IIS 6.0 With ASP.NET
If d string is fixed then one can use like this string s = "(((5+6+4)/15)*100)"; int int1 = Convert.ToInt32(s.Substring(3, 1)); int int2 = Convert.ToInt32(s.Substring(5, 1)); int int3 = Convert.ToInt32(s.Substring(7, 1)); int int4 = Convert.ToInt32(s.Substring(10, 2)); int int5 = Convert.ToInt32(s.Substring(14, 3)); int ans = (((int1+int2+int3)/int4)*int5);
-
11Developer wrote:
first convert the string into integer by Convert.ToInt32 then perform calculations
How will you convert this string "
(((5+6+4)/15)*100))
" as interger ? Did you check the answer of J4amieC ?Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Visit My Latest Article : Beginner's Guide : Exploring IIS 6.0 With ASP.NET
Ya .. Infix to Postfix is the only option.. . :-D :-D
Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.
-
If d string is fixed then one can use like this string s = "(((5+6+4)/15)*100)"; int int1 = Convert.ToInt32(s.Substring(3, 1)); int int2 = Convert.ToInt32(s.Substring(5, 1)); int int3 = Convert.ToInt32(s.Substring(7, 1)); int int4 = Convert.ToInt32(s.Substring(10, 2)); int int5 = Convert.ToInt32(s.Substring(14, 3)); int ans = (((int1+int2+int3)/int4)*int5);
That's great!! I wonder if you can write the same logic for... string s = "(((15+16+14)/115)*1100)"; and what about string s = "(((-5+6+4)/15)*100)"; :)
-
If d string is fixed then one can use like this string s = "(((5+6+4)/15)*100)"; int int1 = Convert.ToInt32(s.Substring(3, 1)); int int2 = Convert.ToInt32(s.Substring(5, 1)); int int3 = Convert.ToInt32(s.Substring(7, 1)); int int4 = Convert.ToInt32(s.Substring(10, 2)); int int5 = Convert.ToInt32(s.Substring(14, 3)); int ans = (((int1+int2+int3)/int4)*int5);
11Developer wrote:
If d string is fixed then one can use like this
This is not like that. This is an
Infix
string. First of all you need to convert into ofPostFix
orPrefix
to perform the calculation as the computer does internally. For that you can simply use Data Structure likeStack
orTree
.Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Visit My Latest Article : Beginner's Guide : Exploring IIS 6.0 With ASP.NET