Not Yet Answered # please send me code of % in calculator

zachattack05 56 Discussion Starter yousafc# ddanbe 2,503 Discussion Starter yousafc# ddanbe 2,503 gmahesh211 Need some help with this Array. I am trying to get the sum of the even numbers and the sum of the odd numbers using a for each loop. I know the answers to what I am trying to achive are sum of even = 84 and the sum of ...

0

I don't really understand what you are trying to achieve. are you trying to find a percentage of a given number or are you trying to multiply a number by a percentage of another number?

A percentage is based on the number 100 and is just some number divided by 100...just rummage through your input and isolate any numbers with a %, drop the % symbol, divide the number by 100 and finish the rest of the math.

Your example of 10*100% is confusing though...you can't multiply 10 by 100% because the 100% is out of context. 100% of what? 50? 20? 3.14? I'd recommend you first find a different input method because the string you gave as an example doesn't make much sense...I'm assuming you want to find 100% of 10...which is 10 of course but let's say you want 50% of 10 instead...

The real math is 10*0.5 = 5...so, just isolate the percentage (50%) drop the % sign and divide 50 by 100 = 0.5 and then move on with the math 10*0.5.

Sorry if that doesn't make sense, but the example is a bit confusing to me.

Is this a console program or winforms? If it's a console it might be more difficult because you need to work with a string instead of having a input box. But I could be wrong...I don't like console programs...never made one.

Another consideration is multiple operators...what would your program do if given this: 10*100%*50? Just something to ponder...

0

Sir ,Permalink

(Please Check this code and find out what i am doing wrong)

```
}
// (Result Card)
// math+english+urdu
private void btnsum_Click(object sender, EventArgs e)
{
decimal mh = Convert.ToDecimal(txtMath.Text);
decimal en = Convert.ToDecimal (txtEnglish.Text);
decimal ur= Convert.ToDecimal(txtUrdu.Text);
decimal t = mh + en + ur;
lbltotal.Text = t.ToString();
// Declare percentage
/*
* when i want show percentage in label called lblpercentshow
* it give error ( c# codeError 1 Cannot implicitly convert type 'decimal' to 'string)
please send me code of percentage
* how can i get percentage in label1
*/
lblpercentshow.Text = t / 30 * 100;
```

*Edited 3 Years Ago by Dani*: Formatting fixed

1

```
decimal calculation = t/30*100;
lblpercentshow.Text = calculation.ToString();
```

You first have to convert your decimal to a string, before you can assign it to a string.

0

Oh Sir Permalink "?You solved my problem "I am very thanks full to You. you are so good

Thanks Thanks Thanks once again Thanks.I am very happy.This code wasted my 3 days.

1

Perhaps you could mark this thread as solved.

Kind regards and happy computing,

Sir ddanbe Permalink :)

-1

am creating the two textboxes in c# enter the username&password that two textboxes to retrive the data through sql & check it correct/wrong

once correct open the windows form

wrong not open windows

please send me code

This article has been dead for over six months. Start a new discussion instead.

Recommended Articles

When I execute this progammatically, I get a table with row heights much larger than when I do this manually.

Note : Sel is the Word.Selection object and the Clipboard contains an Excel Table.

```
public void AddClipboard()
{
Sel.PasteExcelTable(false,false, false);
var t = Sel.Tables[Sel.Tables.Count];
t.AutoFitBehavior(Word.WdAutoFitBehavior.wdAutoFitContent);
}
```

the function that I created to find the ...