Math output

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jul 2009
Posts: 126
Reputation: vinnijain is an unknown quantity at this point 
Solved Threads: 10
vinnijain vinnijain is offline Offline
Junior Poster

Re: Math output

 
0
  #21
Oct 2nd, 2009
Thanks Mr. Scott.
I have already done this. But,problem is that it is not displaying it as the fraction , its interpreting it as values in brackets.
The application is attached here with modifications.
Kindly help me regarding this................
Attached Files
File Type: zip math output.zip (1.01 MB, 1 views)
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,285
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 586
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: Math output

 
1
  #22
Oct 2nd, 2009
vinnijan,

You really need to try to figure this out. The code works but you implemented it incorrectly. You're not even trying to learn what the code does but rather seeing the code does not fit your solution as-is then posting back here with another question.

Make this change:
  1. //const string txtBoxInput = @"()/()";
  2. string txtBoxInput = textBoxEquation.Text;
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 126
Reputation: vinnijain is an unknown quantity at this point 
Solved Threads: 10
vinnijain vinnijain is offline Offline
Junior Poster

Re: Math output

 
0
  #23
Oct 2nd, 2009
here I have attested the thumbnail of my output , in which its showing bracket and not the fraction form which we see in books.
Actually when I am entering bracket format in textbox which is user friendly but in math format output I want the fraction form which we see in books.
In textbox I want bracket only but in math format I want it in actual fraction like in books.
Kindly give me some solution..........
Attached Files
File Type: zip New Picture.zip (17.1 KB, 2 views)
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 386
Reputation: Ryshad has a spectacular aura about Ryshad has a spectacular aura about 
Solved Threads: 69
Ryshad's Avatar
Ryshad Ryshad is offline Offline
Posting Whiz

Re: Math output

 
1
  #24
Oct 2nd, 2009
Vinnijain,

Here at Daniweb we have a policy of helping those who help themselves.
sknake has now given you all the code you need to take the input fromthe textbox and convert it to a latex format string:

  1. const string matchNumerator = @"\((?<Numerator>[\d,]*(\.\d*))\)";
  2. const string matchDenominator = @"\((?<Denominator>[\d,]*(\.\d*))\)";
  3. const string matchBoth = matchNumerator + @"\/" + matchDenominator;
  4.  
  5. //Here is the change he told you to make
  6. //const string txtBoxInput = @"()/()";
  7. string txtBoxInput = textBoxEquation.Text;
  8.  
  9. System.Text.RegularExpressions.Match m = System.Text.RegularExpressions.Regex.Match(txtBoxInput, matchBoth);
  10. if (m.Success)
  11. {
  12. decimal dNumerator, dDenominator;
  13. if (decimal.TryParse(m.Groups["Numerator"].Value, out dNumerator) && decimal.TryParse(m.Groups["Denominator"].Value, out dDenominator))
  14. {
  15.  
  16. //and this right here is your string in latex format
  17. string latex = @"\frac {" + dNumerator.ToString() + "}{" + dDenominator.ToString() + "}";
  18. decimal valueOut = dNumerator / dDenominator;
  19. System.Diagnostics.Debugger.Break();
  20. }

Learning to code involves experimenting with new concepts. You have been shown everything you need to do to solve your problem, now you need to examine the code you have been given, work out what it is doing and apply that to your solution.
We are happy to help, but the only way your coding will move forward is if you take the time to understand each aspect of the project
Last edited by Ryshad; Oct 2nd, 2009 at 8:13 am.
Please don't take for granted the work that solvers do for you. Take the time to fully understand the code they give you so that you might adapt it to future problems.

"Learning is more than absorbing facts, it is acquiring understanding.” - William Arthur Ward
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 126
Reputation: vinnijain is an unknown quantity at this point 
Solved Threads: 10
vinnijain vinnijain is offline Offline
Junior Poster

Re: Math output

 
0
  #25
Oct 2nd, 2009
Hi Ryshad,
I understood the code.
As I am new to C#.NET , thats why I need your guidance to learn more new concepts.
I just need hint to proceed further..........
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 386
Reputation: Ryshad has a spectacular aura about Ryshad has a spectacular aura about 
Solved Threads: 69
Ryshad's Avatar
Ryshad Ryshad is offline Offline
Posting Whiz

Re: Math output

 
0
  #26
Oct 2nd, 2009
Im not sure i understand what you need a hint with?
I made the changes that sknake gave you and put it all together into the code in my last post. That code will take the text from the textbox, locate "(number1)/(number2)" and convert it into "\frac {number1}{number2}" stored in the variable called latex.

Isnt that what your question required?
Please don't take for granted the work that solvers do for you. Take the time to fully understand the code they give you so that you might adapt it to future problems.

"Learning is more than absorbing facts, it is acquiring understanding.” - William Arthur Ward
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 126
Reputation: vinnijain is an unknown quantity at this point 
Solved Threads: 10
vinnijain vinnijain is offline Offline
Junior Poster

Re: Math output

 
1
  #27
Oct 2nd, 2009
Ryshad,
The code which I am using is as follows:
  1. textBoxEquation.AppendText("()/()");
  2. this.textBoxEquation.Focus();
  3.  
  4.  
  5. const string matchNumerator = @"\((?<Numerator>[\d,]*(\.\d*))\)";
  6. const string matchDenominator = @"\((?<Denominator>[\d,]*(\.\d*))\)";
  7. const string matchBoth = matchNumerator + @"\/" + matchDenominator;
  8. //Here is the change he told you to make
  9.  
  10. //const string txtBoxInput = @"()/()";
  11.  
  12. string txtBoxInput = textBoxEquation.Text;
  13. System.Text.RegularExpressions.Match m = System.Text.RegularExpressions.Regex.Match(txtBoxInput, matchBoth);
  14. if (m.Success)
  15. {
  16. decimal dNumerator, dDenominator;
  17. if (decimal.TryParse(m.Groups["Numerator"].Value, out dNumerator) && decimal.TryParse(m.Groups["Denominator"].Value, out dDenominator))
  18. {
  19. //and this right here is your string in latex format
  20. string latex = @"\frac {" + dNumerator.ToString() + "}{" + dDenominator.ToString() + "}";
  21. decimal valueOut = dNumerator / dDenominator;
  22. System.Diagnostics.Debugger.Break();
  23.  
  24. }
  25.  
  26. }
Since I have made for all mathematical symbols and the mathematical equation can be the combination of any symbol.So when we click on any of the math symbol ,it is appended in the textbox.So,when i am using :
  1. string txtBoxInput = textBoxEquation.Text;
It means complete textbox string is assigned to txtBoxInput.
So how can I get fraction value for this "()/()" when its being used with other math symbols too..........
If I would be inserting only "()/()" in textbox it will generate equivalent fraction but not when its being used with other symbols too.........
I want the output as seen in the attached thumbnail
i think you understand what I am trying to say..........
Last edited by vinnijain; Oct 2nd, 2009 at 9:42 am.
Attached Thumbnails
fractions_Full.jpg  
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 386
Reputation: Ryshad has a spectacular aura about Ryshad has a spectacular aura about 
Solved Threads: 69
Ryshad's Avatar
Ryshad Ryshad is offline Offline
Posting Whiz

Re: Math output

 
0
  #28
Oct 2nd, 2009
If im not mistaken you are placing that code inside the event handler for the "÷" button. You only need to parse the data using this code when you update the equation image.

The code you have been given will match a single instance of ()/() in the string and convert it. You need to modify it to find multiple instances. You will also need to modify the Regular Expressions to match other kinds of symbols. The links i gave you originally will have all the info you need on writing your own regular expressions.
Please don't take for granted the work that solvers do for you. Take the time to fully understand the code they give you so that you might adapt it to future problems.

"Learning is more than absorbing facts, it is acquiring understanding.” - William Arthur Ward
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 126
Reputation: vinnijain is an unknown quantity at this point 
Solved Threads: 10
vinnijain vinnijain is offline Offline
Junior Poster

Re: Math output

 
0
  #29
Oct 2nd, 2009
Originally Posted by Ryshad View Post
If im not mistaken you are placing that code inside the event handler for the "÷" button. You only need to parse the data using this code when you update the equation image.

The code you have been given will match a single instance of ()/() in the string and convert it. You need to modify it to find multiple instances. You will also need to modify the Regular Expressions to match other kinds of symbols. The links i gave you originally will have all the info you need on writing your own regular expressions.
The code for the event handler for the "÷" button is:
  1. private void button3_Click(object sender, EventArgs e)
  2. {
  3. textBoxEquation.AppendText("÷");
  4. this.textBoxEquation.Focus();
  5. }
  6.  
  7. private void textBoxEquation_TextChanged(object sender, System.EventArgs e)
  8. {
  9. WriteEquation(FormatText(textBoxEquation.Text));
  10. }
  11.  
  12. private string FormatText(string input)
  13. {
  14. input = input.Replace("÷", "\\div");
  15. input = input.Replace("π", "\\pi");
  16. input = input.Replace("θ", "\\theta");
  17. input = input.Replace("∞", "\\infty");
  18. return input;
  19. }

Also I want to ask you that when you executed the code ,you were getting the equivalent fraction the values in bracket format?Because I was not getting fraction format as in thumbnail.
Last edited by vinnijain; Oct 2nd, 2009 at 10:11 am.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 126
Reputation: vinnijain is an unknown quantity at this point 
Solved Threads: 10
vinnijain vinnijain is offline Offline
Junior Poster

Re: Math output

 
-1
  #30
Oct 4th, 2009
I think nobody on daniweb is able to solve my problem.........
Was It so difficult ?
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC