No syntax errors, but program does not produce any results

Eysaak

I have to create a program for class. My applications needs to have value returning methods for OilLubeCharges(), FlushCharges(), MiscCharges(), OtherCharges(), TaxCharges(), TotalCharges().

It needs to have void methods for ClearOilLube(), ClearFlushes(), ClearMisc(), ClearOther(), ClearFees().

Currently my code has no syntax errors, however when I compile it it does not calculate anything. The calculate, clear, and exit buttons also do not work. Any assistance as to why these issues are occurring would be appreciated. Below is my code.

public partial class Form1 : Form
{
    public Form1() 
    {
        InitializeComponent();
    }

    private void CalcButton_Click(object sender, EventArgs e)
    {
        OilLubeCharges();
        FlushCharges();
        MiscCharges();
        OtherCharges();
        TaxCharges();
        TotalCharges();
    }

    private void ClearButton_Click(object sender, EventArgs e)
    {
        oilCheckBox.Checked = false;
        lubeCheckBox.Checked = false;
        radFlushBox.Checked = false;
        tranFlushBox.Checked = false;
        insCheckBox.Checked = false;
        mufCheckBox.Checked = false;
        tireCheckBox.Checked = false;
        partsTextBox.Text = "";
        laborTextBox.Text = "";
        serLabTotalTextBox.Text = "";
        partsTotalTextBox.Text = "";
        taxPartsTextBox.Text = "";
        totalFeesTextBox.Text = "";
    }

    private void ExitButton_Click(object sender, EventArgs e)
    {
        this.Close();
    }

    private int OilLubeCharges()
    {
        int total = 0;

        if (oilCheckBox.Checked)
        {
            total += 26;
            serLabTotalTextBox.Text = total.ToString("c");
        }

        if (lubeCheckBox.Checked)
        {
            total += 18;
            serLabTotalTextBox.Text = total.ToString("c");
            return total;
        }
        else
        {
            return total;
        }
    }

    private int FlushCharges()
    {
        int total = 0;

        if (radFlushBox.Checked)
        {
            total += 30;
            serLabTotalTextBox.Text = total.ToString("c");
        }

        if (tranFlushBox.Checked)
        {
            total += 80;
            serLabTotalTextBox.Text = total.ToString("c");
            return total;
        }
        else
        {
            return total;
        }
    }

    private int MiscCharges()
    {
        int total = 0;

        if (insCheckBox.Checked)
        {
            total += 15;
            serLabTotalTextBox.Text = total.ToString("c");
        }

        if (mufCheckBox.Checked)
        {
            total += 100;
            serLabTotalTextBox.Text = total.ToString("c");
        }

        if (tireCheckBox.Checked)
        {
            total += 20;
            serLabTotalTextBox.Text = total.ToString("c");
            return total;
        }
        else
        {
            return total;
        }
    }

    private int OtherCharges()
    {
        int total = 0;
        int parts = 0;
        int labor = 0;

        if (int.TryParse(partsTextBox.Text, out parts))
        {
            partsTextBox.Text = parts.ToString("c");
            total = parts;
        }

        if (int.TryParse(laborTextBox.Text, out labor))
        {
            laborTextBox.Text = labor.ToString("c");
            return total;
        }
        else
        {
            return total;
        }
    }

    private decimal TaxCharges()
    {
        decimal parts = 0;
        decimal partsTax;

        partsTax = parts * .06m;
        taxPartsTextBox.Text = partsTax.ToString("c");
        return partsTax;
    }

    private decimal TotalCharges()
    {
        decimal total = 0;

        total = OilLubeCharges() + FlushCharges() + MiscCharges() + TaxCharges() + OtherCharges();
        totalFeesTextBox.Text = total.ToString("c");
        return total;
    }
}
Eric H

As stated in the comments above, most likely your events are not hooked up to your buttons. You can do this several ways; typically it's done in the designer.

To know for sure if this is the cause, try this:

public Form1() 
{
    InitializeComponent();
    CalcButton.Click += CalcButton_Click;
}

Note that this assumes your button is named "CalcButton". You can see whether that's true in the designer as well.

If that works, you need to do the same with the rest of your buttons either the same way or by selecting the method in the designer for the button.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Intellij does not show any errors in the syntax/does not give any suggestions

Why does this LinqPad program produce different results on the second run?

This java program produce unwanted results

Unending Python Program which does not show results or errors

SlidingEventTimeWindows does not produce any output

Syntax errors in pizza order program

Does any floating point-intensive code produce bit-exact results in any x86-based architecture?

Why does 'npm doctor' produce permission errors?

Why does dplyr fails to produce by line results?

PHP eval does not produce expected results

Why does Autolayout not produce consistent results?

Tuning hyperparameters in mlr does not produce sensible results?

Why does == and equals produce different results?

Why does "hexdec" produce different results?

Does TRUNCATE and DELETE produce same results?

Why does VPMOVMSKB appear to produce incorrect results?

Does .bashrc contain syntax errors?

Why does this decorator program produce an unexpected output?

Why does this program only produce three warnings?

Simple Ruby program does not produce output

Why does this assembly program produce no output?

Why writing anything after the fileName of a #include directive does't give any errors in a C program?

How does a program with "U" undefined symbol type in an object file, compiles without any linker errors?

Shadowing declaration does not produce any warnings

Docker run does not produce any endpoint

Why does "printf" not produce any output?

Dataflow job does not any produce output

which.min does not produce any output

Command executed with Paramiko does not produce any output