How do i get the total average?

Rob Manuel
private void txtFinal_Leave_1(object sender, EventArgs e)
    {
        int prelim;
        int midterm;
        int final;
        decimal average;
        string remarks;

        prelim = int.Parse(txtPrelim.Text);
        midterm = int.Parse(txtMidterm.Text);
        final = int.Parse(txtFinal.Text);

        average = (prelim + midterm + final) / 3;
        txtAverage.Text = average.ToString();

        if (average >= 75)
        {
            remarks = "passed";
        }
        else
        {
            remarks = "failed";
        }
        txtRemarks.Text = remarks;


       // this is the output 83 passed
       // I want to be like this 83.25 passed

    }
mybirthname
average = (prelim + midterm + final) / 3.0m;

This will fix your problem.

Int is an integer type; dividing two ints performs an integer division, i.e. the fractional part is truncated since it can't be stored in the result type (also int!). Decimal, by contrast, has got a fractional part. By invoking Decimal.Divide, your int arguments get implicitly converted to Decimals.

You can enforce non-integer division on int arguments by explicitly casting at least one of the arguments to a floating-point type, e.g.: 3.0m this is casting to decimal !

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I calculate the total and average of all dice rolls?

From Dev

How do I get a moving average?

From Java

How do I get the numbers in a String and then calculate the average of them?

From Dev

how do I get the average of lookup value from ssrs?

From Dev

How do I get average of one array and compare it with a value

From Dev

How do I add 2 arrays together and get the average of the sum?

From Dev

How do I get average rating and round up to nearest 1?

From Dev

How do I cut my EMG signal and get an average signal?

From Dev

How do I calculate the average by using the get method for class objects?

From Dev

How do I get the Average Method to give correct output in Java

From Dev

How do I get the average row count per day of data?

From Dev

How do I get the average of a count in Microsoft SQL Server 2008

From Dev

Python, How do I get the average from a tuple from MySQL?

From Dev

How do I get the total number of distinct values in a column in a CSV?

From Dev

How do I get the last iteration of foreach if the total is unknown

From Dev

How do I get the total sum of nested arrays in Reactjs?

From Dev

How do I get total text and voice channel count in numbers

From Dev

How do I get a single total of lines with `wc -l`?

From Dev

How do I get total Qty using one linq query?

From Dev

How do I get total number of objects in a variable only once?

From Dev

How do I get the total size of everything in a directory in one line?

From Dev

How can I get the total?

From Dev

How do you determine the average total of a column in Postgresql?

From Dev

How to get total of multiple columns from sum of quantity and average of price?

From Dev

How to get total of multiple columns from sum of quantity and average of price?

From Dev

How do I get the total number of records before I run limit when using Aggregation

From Dev

How do I calculate an average date in SQL?

From Dev

How do I display the average of my array?

From Dev

how do I find the average in a Java LinkedList?

Related Related

  1. 1

    How do I calculate the total and average of all dice rolls?

  2. 2

    How do I get a moving average?

  3. 3

    How do I get the numbers in a String and then calculate the average of them?

  4. 4

    how do I get the average of lookup value from ssrs?

  5. 5

    How do I get average of one array and compare it with a value

  6. 6

    How do I add 2 arrays together and get the average of the sum?

  7. 7

    How do I get average rating and round up to nearest 1?

  8. 8

    How do I cut my EMG signal and get an average signal?

  9. 9

    How do I calculate the average by using the get method for class objects?

  10. 10

    How do I get the Average Method to give correct output in Java

  11. 11

    How do I get the average row count per day of data?

  12. 12

    How do I get the average of a count in Microsoft SQL Server 2008

  13. 13

    Python, How do I get the average from a tuple from MySQL?

  14. 14

    How do I get the total number of distinct values in a column in a CSV?

  15. 15

    How do I get the last iteration of foreach if the total is unknown

  16. 16

    How do I get the total sum of nested arrays in Reactjs?

  17. 17

    How do I get total text and voice channel count in numbers

  18. 18

    How do I get a single total of lines with `wc -l`?

  19. 19

    How do I get total Qty using one linq query?

  20. 20

    How do I get total number of objects in a variable only once?

  21. 21

    How do I get the total size of everything in a directory in one line?

  22. 22

    How can I get the total?

  23. 23

    How do you determine the average total of a column in Postgresql?

  24. 24

    How to get total of multiple columns from sum of quantity and average of price?

  25. 25

    How to get total of multiple columns from sum of quantity and average of price?

  26. 26

    How do I get the total number of records before I run limit when using Aggregation

  27. 27

    How do I calculate an average date in SQL?

  28. 28

    How do I display the average of my array?

  29. 29

    how do I find the average in a Java LinkedList?

HotTag

Archive