ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 22 May 2017 My Price 8.00

C# code I wrote inside of Microsoft Visual Studio

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;




}

}
}













































































Answers

(11)
Status NEW Posted 22 May 2017 03:05 AM My Price 8.00

-----------

Not Rated(0)