i got error found in percentage ,so pls solve my error,i have great hope on u.
i placed here my totally code ,for explain u.'
so please refer my code & get help for me found percentage in this calculator.
default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Calcy.aspx.cs" Inherits="Calcy" %>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class Calcy : System.Web.UI.Page
{
int a;
//int result;
//int value1;
//int percentage;
int count;
int totalcount;
decimal val1;
decimal val2;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnBack_Click(object sender, EventArgs e)
{
int d;
d = txtAns.Text.Length;
txtAns.Text = txtAns.Text.Remove(d - 1, 1);
TextBox2.Text = TextBox2.Text.Remove(d - 1, 1);
}
protected void btnClear_Click(object sender, EventArgs e)
{
txtAns.Text = "";
TextBox2.Text = "";
}
protected void btnCE_Click(object sender, EventArgs e)
{
txtAns.Text = txtAns.Text + "";
txtAns.Text = "";
TextBox2.Text = "";
}
protected void btn7_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn7.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn8_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn8.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn9_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn9.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn4_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn4.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn5_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn5.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn6_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn6.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn1_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn1.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn2_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn2.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn3_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn3.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn0_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn0.Text;
TextBox2.Text += txtAns.Text;
}
protected void btnDot_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btnDot.Text;
TextBox2.Text += txtAns.Text;
}
protected void btnEqual_Click(object sender, EventArgs e)
{
string str = txtAns.Text;
object obj;
DataTable dt = new DataTable();
obj = dt.Compute(str, null);
txtAns.Text = obj.ToString();
TextBox2.Text = "";
}
protected void btnAdd_Click(object sender, EventArgs e)
{
a = 0;
txtAns.Text = txtAns.Text + btnAdd.Text;
TextBox2.Text = "";
}
protected void btnSub_Click(object sender, EventArgs e)
{
a = 0;
txtAns.Text = TextBox2.Text + btnSub.Text;
TextBox2.Text = "";
}
protected void btnMul_Click(object sender, EventArgs e)
{
a = 0;
txtAns.Text = txtAns.Text + btnMul.Text;
//TextBox2.Text = "";
}
protected void btnDiv_Click(object sender, EventArgs e)
{
a = 0;
txtAns.Text = txtAns.Text + btnDiv.Text;
TextBox2.Text = "";
}
protected void btnPlusMinus_Click(object sender, EventArgs e)
{
a = 0;
decimal currVal = decimal.Parse(txtAns.Text);
currVal = -currVal;
txtAns.Text = currVal.ToString();
TextBox2.Text = "";
}
protected void btn1byx_Click(object sender, EventArgs e)
{
a = 0;
decimal value = decimal.Parse(txtAns.Text);
value = 1 / value;
txtAns.Text = value.ToString();
TextBox2.Text = "";
}
protected void btnSqrt_Click(object sender, EventArgs e)
{
a = 0;
txtAns.Text = Math.Sqrt(Convert.ToDouble(txtAns.Text)).ToString();
TextBox2.Text = "";
}
protected void btnPercentage_Click(object sender, EventArgs e)
{
//double percentage = (double.Parse(txtAns.Text) * double.Parse(txtAns.Text)) / 100;
//txtAns.Text = percentage.ToString();
//a = 0;
//value = Convert.ToInt32(txtAns.Text);
//result = Convert.ToInt32(value * value);
//txtAns.Text = result.ToString();
//display = double.Parse(TextBox2.Text);
//decimal value1 = decimal.Parse(txtAns.Text);
//txtAns.Text = (value * display).ToString();
////txtAns.Text = value.ToString();
////txtAns.Text = value1.ToString();
//a = 0;
//percentage = (Convert.ToInt32(txtAns.Text) * Convert.ToInt32(txtAns.Text)).ToString();
//a = 0;
//double value = double.Parse(txtAns.Text);
//double percentage = 0.01;
//double comission = value * percentage;
//txtAns.Text = comission.ToString();
//TextBox2.Text = "";
//Double a = no1;
//Double b = no2;
//Double percentage = (a * b / 100);
//// to output the result
//txtAns.Text = percentage.ToString().Trim();
// txtAns.Text = (value1 * percentage / 100).ToString();
//var result = (percentage / 100) * value1;
//txtAns.Text = result.ToString();
//if (a == 0)
//{
// TextBox2.Text = "";
// a = 1;
//}
// txtAns.Text = ((percentage * .01) * value1).ToString();
//count = ((count * 100) / totalcount);
//txtAns.Text = count.ToString().Trim();
//if (txtAns.Text != string.Empty)
//{
// double chk = Convert.ToDouble("1") / Convert.ToDouble(txtAns.Text);
// txtAns.Text = chk.ToString();
//}
txtAns.Text = Convert.ToString(Convert.ToInt32(val1) * Convert.ToInt32(val2) / 100);
}
}using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class Calcy : System.Web.UI.Page
{
int a;
//int result;
//int value1;
//int percentage;
int count;
int totalcount;
decimal val1;
decimal val2;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnBack_Click(object sender, EventArgs e)
{
int d;
d = txtAns.Text.Length;
txtAns.Text = txtAns.Text.Remove(d - 1, 1);
TextBox2.Text = TextBox2.Text.Remove(d - 1, 1);
}
protected void btnClear_Click(object sender, EventArgs e)
{
txtAns.Text = "";
TextBox2.Text = "";
}
protected void btnCE_Click(object sender, EventArgs e)
{
txtAns.Text = txtAns.Text + "";
txtAns.Text = "";
TextBox2.Text = "";
}
protected void btn7_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn7.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn8_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn8.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn9_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn9.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn4_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn4.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn5_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn5.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn6_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn6.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn1_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn1.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn2_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn2.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn3_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn3.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn0_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn0.Text;
TextBox2.Text += txtAns.Text;
}
protected void btnDot_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btnDot.Text;
TextBox2.Text += txtAns.Text;
}
protected void btnEqual_Click(object sender, EventArgs e)
{
string str = txtAns.Text;
object obj;
DataTable dt = new DataTable();
obj = dt.Compute(str, null);
txtAns.Text = obj.ToString();
TextBox2.Text = "";
}
protected void btnAdd_Click(object sender, EventArgs e)
{
a = 0;
txtAns.Text = txtAns.Text + btnAdd.Text;
TextBox2.Text = "";
}
protected void btnSub_Click(object sender, EventArgs e)
{
a = 0;
txtAns.Text = TextBox2.Text + btnSub.Text;
TextBox2.Text = "";
}
protected void btnMul_Click(object sender, EventArgs e)
{
a = 0;
txtAns.Text = txtAns.Text + btnMul.Text;
//TextBox2.Text = "";
}
protected void btnDiv_Click(object sender, EventArgs e)
{
a = 0;
txtAns.Text = txtAns.Text + btnDiv.Text;
TextBox2.Text = "";
}
protected void btnPlusMinus_Click(object sender, EventArgs e)
{
a = 0;
decimal currVal = decimal.Parse(txtAns.Text);
currVal = -currVal;
txtAns.Text = currVal.ToString();
TextBox2.Text = "";
}
protected void btn1byx_Click(object sender, EventArgs e)
{
a = 0;
decimal value = decimal.Parse(txtAns.Text);
value = 1 / value;
txtAns.Text = value.ToString();
TextBox2.Text = "";
}
protected void btnSqrt_Click(object sender, EventArgs e)
{
a = 0;
txtAns.Text = Math.Sqrt(Convert.ToDouble(txtAns.Text)).ToString();
TextBox2.Text = "";
}
protected void btnPercentage_Click(object sender, EventArgs e)
{
//double percentage = (double.Parse(txtAns.Text) * double.Parse(txtAns.Text)) / 100;
//txtAns.Text = percentage.ToString();
//a = 0;
//value = Convert.ToInt32(txtAns.Text);
//result = Convert.ToInt32(value * value);
//txtAns.Text = result.ToString();
//display = double.Parse(TextBox2.Text);
//decimal value1 = decimal.Parse(txtAns.Text);
//txtAns.Text = (value * display).ToString();
////txtAns.Text = value.ToString();
////txtAns.Text = value1.ToString();
//a = 0;
//percentage = (Convert.ToInt32(txtAns.Text) * Convert.ToInt32(txtAns.Text)).ToString();
//a = 0;
//double value = double.Parse(txtAns.Text);
//double percentage = 0.01;
//double comission = value * percentage;
//txtAns.Text = comission.ToString();
//TextBox2.Text = "";
//Double a = no1;
//Double b = no2;
//Double percentage = (a * b / 100);
//// to output the result
//txtAns.Text = percentage.ToString().Trim();
// txtAns.Text = (value1 * percentage / 100).ToString();
//var result = (percentage / 100) * value1;
//txtAns.Text = result.ToString();
//if (a == 0)
//{
// TextBox2.Text = "";
// a = 1;
//}
// txtAns.Text = ((percentage * .01) * value1).ToString();
//count = ((count * 100) / totalcount);
//txtAns.Text = count.ToString().Trim();
//if (txtAns.Text != string.Empty)
//{
// double chk = Convert.ToDouble("1") / Convert.ToDouble(txtAns.Text);
// txtAns.Text = chk.ToString();
//}
txtAns.Text = Convert.ToString(Convert.ToInt32(val1) * Convert.ToInt32(val2) / 100);
}
default.aspx.cs
}using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class Calcy : System.Web.UI.Page
{
int a;
//int result;
//int value1;
//int percentage;
int count;
int totalcount;
decimal val1;
decimal val2;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnBack_Click(object sender, EventArgs e)
{
int d;
d = txtAns.Text.Length;
txtAns.Text = txtAns.Text.Remove(d - 1, 1);
TextBox2.Text = TextBox2.Text.Remove(d - 1, 1);
}
protected void btnClear_Click(object sender, EventArgs e)
{
txtAns.Text = "";
TextBox2.Text = "";
}
protected void btnCE_Click(object sender, EventArgs e)
{
txtAns.Text = txtAns.Text + "";
txtAns.Text = "";
TextBox2.Text = "";
}
protected void btn7_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn7.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn8_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn8.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn9_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn9.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn4_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn4.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn5_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn5.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn6_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn6.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn1_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn1.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn2_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn2.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn3_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn3.Text;
TextBox2.Text += txtAns.Text;
}
protected void btn0_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btn0.Text;
TextBox2.Text += txtAns.Text;
}
protected void btnDot_Click(object sender, EventArgs e)
{
if (a == 0)
{
TextBox2.Text = "";
a = 1;
}
txtAns.Text = txtAns.Text + btnDot.Text;
TextBox2.Text += txtAns.Text;
}
protected void btnEqual_Click(object sender, EventArgs e)
{
string str = txtAns.Text;
object obj;
DataTable dt = new DataTable();
obj = dt.Compute(str, null);
txtAns.Text = obj.ToString();
TextBox2.Text = "";
}
protected void btnAdd_Click(object sender, EventArgs e)
{
a = 0;
txtAns.Text = txtAns.Text + btnAdd.Text;
TextBox2.Text = "";
}
protected void btnSub_Click(object sender, EventArgs e)
{
a = 0;
txtAns.Text = TextBox2.Text + btnSub.Text;
TextBox2.Text = "";
}
protected void btnMul_Click(object sender, EventArgs e)
{
a = 0;
txtAns.Text = txtAns.Text + btnMul.Text;
//TextBox2.Text = "";
}
protected void btnDiv_Click(object sender, EventArgs e)
{
a = 0;
txtAns.Text = txtAns.Text + btnDiv.Text;
TextBox2.Text = "";
}
protected void btnPlusMinus_Click(object sender, EventArgs e)
{
a = 0;
decimal currVal = decimal.Parse(txtAns.Text);
currVal = -currVal;
txtAns.Text = currVal.ToString();
TextBox2.Text = "";
}
protected void btn1byx_Click(object sender, EventArgs e)
{
a = 0;
decimal value = decimal.Parse(txtAns.Text);
value = 1 / value;
txtAns.Text = value.ToString();
TextBox2.Text = "";
}
protected void btnSqrt_Click(object sender, EventArgs e)
{
a = 0;
txtAns.Text = Math.Sqrt(Convert.ToDouble(txtAns.Text)).ToString();
TextBox2.Text = "";
}
protected void btnPercentage_Click(object sender, EventArgs e)
{
//double percentage = (double.Parse(txtAns.Text) * double.Parse(txtAns.Text)) / 100;
//txtAns.Text = percentage.ToString();
//a = 0;
//value = Convert.ToInt32(txtAns.Text);
//result = Convert.ToInt32(value * value);
//txtAns.Text = result.ToString();
//display = double.Parse(TextBox2.Text);
//decimal value1 = decimal.Parse(txtAns.Text);
//txtAns.Text = (value * display).ToString();
////txtAns.Text = value.ToString();
////txtAns.Text = value1.ToString();
//a = 0;
//percentage = (Convert.ToInt32(txtAns.Text) * Convert.ToInt32(txtAns.Text)).ToString();
//a = 0;
//double value = double.Parse(txtAns.Text);
//double percentage = 0.01;
//double comission = value * percentage;
//txtAns.Text = comission.ToString();
//TextBox2.Text = "";
//Double a = no1;
//Double b = no2;
//Double percentage = (a * b / 100);
//// to output the result
//txtAns.Text = percentage.ToString().Trim();
// txtAns.Text = (value1 * percentage / 100).ToString();
//var result = (percentage / 100) * value1;
//txtAns.Text = result.ToString();
//if (a == 0)
//{
// TextBox2.Text = "";
// a = 1;
//}
// txtAns.Text = ((percentage * .01) * value1).ToString();
//count = ((count * 100) / totalcount);
//txtAns.Text = count.ToString().Trim();
//if (txtAns.Text != string.Empty)
//{
// double chk = Convert.ToDouble("1") / Convert.ToDouble(txtAns.Text);
// txtAns.Text = chk.ToString();
//}
txtAns.Text = Convert.ToString(Convert.ToInt32(val1) * Convert.ToInt32(val2) / 100);
}
}
4 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sujeet SumanPosted Sep 21, 2015, 11:17 AM
Afzaal Ahmad ZeeshanPosted Sep 21, 2015, 10:04 AM
nayak armyPosted Sep 21, 2015, 8:42 AM
Afzaal Ahmad ZeeshanPosted Sep 21, 2015, 8:17 AM