17.04.2013 Views

Linguagem de Programação I (linguagem C#) - Alcides Maya ...

Linguagem de Programação I (linguagem C#) - Alcides Maya ...

Linguagem de Programação I (linguagem C#) - Alcides Maya ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

using System;<br />

using System.Collections.Generic;<br />

using System.Linq;<br />

using System.Text;<br />

namespace ExemploSwitch<br />

{<br />

class ExemploSwitch<br />

{<br />

static void Main(string[] args)<br />

{<br />

switch (operador)<br />

resultado);<br />

resultado);<br />

resultado);<br />

resultado);<br />

}<br />

}<br />

}<br />

double valor1, valor2, resultado;<br />

string operador;<br />

Console.WriteLine(“Digite o primeiro valor: “);<br />

valor1 = double.Parse(Console.ReadLine());<br />

Console.WriteLine(“Digite o segundo valor: “);<br />

valor2 = double.Parse(Console.ReadLine());<br />

Console.WriteLine(“Escolha a operação(+, -, *, /): “);<br />

operador = Console.ReadLine();<br />

{<br />

}<br />

case “+”:<br />

case “-”:<br />

case “*”:<br />

case “/”:<br />

<strong>de</strong>fault :<br />

Console.ReadKey();<br />

resultado = valor1 + valor2;<br />

Console.WriteLine(“O resultado da soma é: “+<br />

break;<br />

resultado = valor2 - valor1;<br />

Console.WriteLine(“O resultado da subtração é: “ +<br />

break;<br />

resultado = valor1 * valor2;<br />

Console.WriteLine(“O resultado da multiplicação é: “ +<br />

break;<br />

resultado = valor1 / valor2;<br />

Console.WriteLine(“O resultado da divisão é: “ +<br />

break;<br />

break;<br />

15<br />

<strong>Linguagem</strong> <strong>C#</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!