3
using System; namespace MediaDoisNumeros { class Program { static void Main(string[] args) { Int16 numero1, numero2; Double media; Console.Write("Digite o numero 1 : "); numero1 = Convert.ToInt16(Console.ReadLine()); Console.Write("Digite o numero 2 : "); numero2 = Convert.ToInt16(Console.ReadLine()); media = (numero1 + numero2) / 2; Console.WriteLine("A média dos dois numeros é {0}", media); Console.ReadKey(); } } }
Printed output on console :
A m ®dia of the two numbers ® 5
How to make it printed correctly :
The average of the two numbers is 5
Welcome, take a [tour] on the site and see [Ask].
– Francisco
Apart from this code having some problems of style and robustness, what’s the problem? The
média
in the text is giving problem? What error pointed? Where is compiling? The file.cs
is recorded in UTF-8 by the editor?– Maniero
The robustness of the code is of no concern. The problem is that accented text is not displayed correctly. Yes The average is not displayed correctly. The error pointed out is how to use accentuation in a Console Application . NET Core project. Yes file . Cs is saved in Unicode ( UTF-8 with signature ) - code page 65001 by the editor.
– Eric Castro
O erro apontado é como utilizar acentuação em um projeto Console Application .NET Core
This is not an error that the compiler points to. It just appears wrong? then the problem must be where it is being shown, as I do not know where it is compiling, running, I can not help.– Maniero
I thank you for trying to understand the problem, but it seems to me that you are not concerned with helping, but rather that I ask the question according to your precepts. I’m sorry I don’t have your level of expertise to ask the question in a way you like.
– Eric Castro
@Ericcastro if I understand correctly, try to do the following: Console.Outputencoding = System.Text.Encoding.UTF8;
– mcamara
@miltoncamara thank you very much guy I just found this solution in stackoverflow in English I just tested worked even, and I saw your answer. Thanks! https://stackoverflow.com/questions/5750203/how-to-write-unicode-characters-to-the-console
– Eric Castro