Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace EX_8
- {
- class Program
- {
- static float CalcularValor(float Litros, float ValorUnit)
- {
- float ValorTotal = (Litros * ValorUnit);
- return ValorTotal;
- }
- static void Main(string[] args)
- {
- //Entrada de dados
- Console.WriteLine("Informe a quantidade de litros vendidos: ");
- float fLitros = Convert.ToSingle(Console.ReadLine());
- Console.WriteLine("informe o tipo de combustível, sendo: (A = Alcool) e (G = Gasolina): ");
- char cCombustivel = Convert.ToChar(Console.ReadLine());
- //Validações e saída dos dados
- if ((cCombustivel == 'A') || (cCombustivel == 'a'))
- {
- float fValorTotal = CalcularValor(fLitros, 2.90f);
- Console.WriteLine("\nO valor total de {0} litros de alcool é de: R$ {1:f2}", fLitros, fValorTotal);
- }
- if ((cCombustivel == 'G') || (cCombustivel == 'g'))
- {
- float fValorTotal = CalcularValor(fLitros, 3.30f);
- Console.WriteLine("\nO valor total de {0} litros de gasolina é de: R$ {1:f2}", fLitros, fValorTotal);
- }
- if ((cCombustivel != 'A') && (cCombustivel != 'a') && (cCombustivel != 'G') && (cCombustivel != 'g'))
- {
- Console.WriteLine("\nTipo de combustível informado inexistente!");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment