Q: How to find the average of the sum of 3 numbers in C# and Visual Basics

+3 votes

I need to write a program that finds the average of the sum of 3 numbers in Visual Basics

asked in C# category by user Jolie Ann

2 Answers

+1 vote

Use these hints:

  1. Declare four variables (a, b, c and average).
  2. Read the user input from the console. (int.Parse(Console.ReadLine());) or double.Parse(Console.ReadLine());
  3. Calculate the average value of the variables by the formulae (a+b+c)/3
  4. Print the result on the console (Console.WriteLine(average));
answered by user andrew
+1 vote
using System;

class Average
    static void Main()

        Console.WriteLine("Please write your 1st number: ");
        double a = double.Parse(Console.ReadLine());

        Console.WriteLine("Please write your 2nd number: ");
        double b = double.Parse(Console.ReadLine());

        Console.WriteLine("Please write your 3rd number: ");
        double c = double.Parse(Console.ReadLine());

        double average = (a + b + c) / 3;
        Console.WriteLine("The average sum of these 3 numbers is: {0:F5}", average);

answered by user sam
edited by user golearnweb