Hi. I wrote this code below to find the average of three numbers. It works, but the answer is always rounded to a whole number. How can I change my code to make this work?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Assignment_1_mcdaniel
{
class Program
{
static void Main(string[] args)
{
int f, s, t, r;
Console.WriteLine("Enter Frst Number:");
f = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter Second Number:");
s = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter Third Number:");
t = Convert.ToInt32(Console.ReadLine());
r = (f + s + t) / 3;
Console.WriteLine("Answer:" + r);
Console.ReadKey();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Assignment_1_mcdaniel
{
class Program
{
static void Main(string[] args)
{
int f, s, t, r;
Console.WriteLine("Enter Frst Number:");
f = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter Second Number:");
s = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter Third Number:");
t = Convert.ToInt32(Console.ReadLine());
r = (f + s + t) / 3;
Console.WriteLine("Answer:" + r);
Console.ReadKey();
}
}
}