The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
This is a C# code I wrote inside of Microsoft Visual Studio. I need someone to check over my work and explain why my calculations always return 0 instead of doing the proper methods that I wrote. Please highlight and fix the errors.
Â
Demo.aspx.cs:
using Assignment5.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Assignment5
{
public partial class Demo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void factorial_Click(object sender, EventArgs e)
{
Operations ans = new Operations();
int userInput = Convert.ToInt32(inputTxt.Text);
result.Text = ans.Factorial().ToString();
}
protected void sum_Click(object sender, EventArgs e)
{
Operations anstwo = new Operations();
int userInput = Convert.ToInt32(inputTxt.Text);
result.Text = anstwo.Sum().ToString();
}
}
}
(Models page)Â Operations.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Assignment5.Models
{
public class Operations
{
private int userInput;
public int UserInput
{
get
{
return this.userInput;
}
set
{
this.userInput = value;
}
}
public int Factorial()
{
int fac = userInput;
for (int i = 1; i {
fac = fac * i;
}
return fac;
}
public int Sum()
{
int sum = userInput;
for (int i = 1; i {
sum = sum + i;
}
return sum;
}
}
}