Storing user-provided values

84 views Asked by At

I am trying to store user-provided values in order to calculate their sum and average for an assignment. I am able to print the values, but not store them.

I am not looking for the answer, but only for guidance.

Thank you for any and all responses.

public class average {
    public int num;
    public double avg;        

    public average() { } // no argument method
    public average(int nums, double avgt) {
        num = nums;
        avg = avgt;
    }
    public int Num {
        get { return num; } // used to get the contents from the main()
        set { num = value; }
    }
    public double Avg {
        get { return avg; }
        set { avg = value; }
    }
    public void print_info() { // prints the final results of code
                               // Cannot get the values to store properly
        Console.WriteLine("The average is {0}, the sum of 10 numbers is {1}", (avg/10),num);
        Console.WriteLine("Press any key to continue . . .");
        Console.ReadLine();
    }   

    {class assignment1 // wrapper class for main
        static void Main(string[] args) {
            int num0;
            int val;

            int nums = 0;
            double avgt = 0.0;

            average num1 = new average(nums, avgt);
            for (val = 0; val < 10; val++) { // loop for user input
                Console.Write("Enter an integer value: ");
                num0 = Convert.ToInt32(Console.ReadLine());  
            }
            num1.print_info(); // calls print_info() method
        }
    }
}
0

There are 0 answers