Hey guys, this is unrelated to SRO but im desperate from help and i know everyone on this forum is really skilled. My computer science 101 class taught me c++ console programming, and now im in an ist class that assumes everyone knows object oriented c# programming. Im really unfamiliar with this and I'm unsure how to use it and im unsure of the syntax. Our assignment is to create an amortization program. It has 4 text boxes. The inputs are Principle, Rate, and Term of loan. The fourth textbox is for the output of the monthly payment that will be calculated from this program. So far what I've done is go into the Private function of each textbox and convert the string to double.
Double Principle = Convert.ToDouble(principle.Text) ;
However, now that I've done that I'm unsure of a few things, since each function for each object is private, how do i call variables from other objects. What i mean is, i have the formula for calculating the monthly payment, but im unsure where in the code to put the formula because if i put it in a private function somewhere, and i call the variable "principle" it doesnt recognize it.
After i get that squared away, im unsure how to code the "submit " button to provide the output in the fourth textbox.
Sorry thats alot, and again sorry this is unrelated to sro. I know the people here are really good and my teacher has yet to email me back and i really need help.
Thanks!
Post your code and I'll try to help ya.
EDIT: Maybe it's this easy:
Code:
public void SubmitButton_Click () //(assign this to the submit button's click event)
{
Double principle = Convert.ToDouble(principleBox.Text);
Double rate = Convert.ToDouble(rateBox.Text);
Double termOfLoan = Convert.ToDouble(termOfLoanBox.Text);
Double result = /* Replace this with your formula. */;
resultBox.Text = result;
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace amortization
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Post your code and I'll try to help ya.
EDIT: Maybe it's this easy:
Code:
public void SubmitButton_Click () //(assign this to the submit button's click event)
{
Double principle = Convert.ToDouble(principleBox.Text);
Double rate = Convert.ToDouble(rateBox.Text);
Double termOfLoan = Convert.ToDouble(termOfLoanBox.Text);
Double result = /* Replace this with your formula. */;
resultBox.Text = result;
}
Im not sure because apparently you cant output to a textbox unless its read only, so im supposed to output it to a label. Not sure how to do that
ok i understand now, and i got it to work with a basic mutliplication formula. Now when i debugged it, if i didnt put an input value in each of the boxes it gave me an error. How do i code a statement that says "if there is no input give error "no input provided"
Thanks so much for your help!