JottaJames

EX_8 C#_ASPNET_03

Mar 27th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.58 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace EX_8
  8. {
  9.     class Program
  10.     {
  11.         static float CalcularValor(float Litros, float ValorUnit)
  12.         {
  13.             float ValorTotal = (Litros * ValorUnit);
  14.  
  15.             return ValorTotal;
  16.         }
  17.  
  18.         static void Main(string[] args)
  19.         {
  20.             //Entrada de dados
  21.             Console.WriteLine("Informe a quantidade de litros vendidos: ");
  22.             float fLitros = Convert.ToSingle(Console.ReadLine());
  23.  
  24.             Console.WriteLine("informe o tipo de combustível, sendo: (A = Alcool) e (G = Gasolina): ");
  25.             char cCombustivel = Convert.ToChar(Console.ReadLine());
  26.  
  27.             //Validações e saída dos dados
  28.             if ((cCombustivel == 'A') || (cCombustivel == 'a'))
  29.             {
  30.                 float fValorTotal = CalcularValor(fLitros, 2.90f);
  31.                 Console.WriteLine("\nO valor total de {0} litros de alcool é de: R$ {1:f2}", fLitros, fValorTotal);
  32.             }
  33.             if ((cCombustivel == 'G') || (cCombustivel == 'g'))
  34.             {
  35.                 float fValorTotal = CalcularValor(fLitros, 3.30f);
  36.                 Console.WriteLine("\nO valor total de {0} litros de gasolina é de: R$ {1:f2}", fLitros, fValorTotal);
  37.             }
  38.  
  39.             if ((cCombustivel != 'A') && (cCombustivel != 'a') && (cCombustivel != 'G') && (cCombustivel != 'g'))
  40.             {
  41.                 Console.WriteLine("\nTipo de combustível informado inexistente!");
  42.             }
  43.  
  44.         }
  45.     }
  46. }
Add Comment
Please, Sign In to add comment