Advertisement
JottaJames

EX_9 C#_ASPNET_03

Mar 27th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.27 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_9
  8. {
  9.     class Program
  10.     {
  11.         static float CalcularValorAPagar(float Quantidade, float Valorunit)
  12.         {
  13.             float fTotalPagar = (Quantidade * Valorunit);
  14.  
  15.             if (Quantidade <= 5.0)
  16.             {
  17.                 float fDesc = 2;
  18.  
  19.                 Console.WriteLine("\n{0} itens à um valor unitário de R$ {1:f2} totalizam R$ {2:f2}", Quantidade, Valorunit, fTotalPagar);
  20.                 Console.WriteLine("Com um desconto concedido de {0}%, o total a pagar pelo cliente é de: R$ {1:f2}", (fDesc), ((fTotalPagar) - (fTotalPagar * (fDesc / 100))));
  21.  
  22.             }
  23.             if ((Quantidade > 5.0) && (Quantidade <= 10.0))
  24.             {
  25.                 float fDesc = 3;
  26.  
  27.                 Console.WriteLine("\n{0} itens à um valor unitário de R$ {1:f2} totalizam R$ {2:f2}", Quantidade, Valorunit, fTotalPagar);
  28.                 Console.WriteLine("Com um desconto concedido de {0}%, o total a pagar pelo cliente é de: R$ {1:f2}", (fDesc), ((fTotalPagar) - (fTotalPagar * (fDesc / 100))));
  29.             }
  30.             if ((Quantidade > 10.0))
  31.             {
  32.                 float fDesc = 5;
  33.  
  34.                 Console.WriteLine("\n{0} itens à um valor unitário de R$ {1:f2} totalizam e R$ {2:f2}", Quantidade, Valorunit, fTotalPagar);
  35.                 Console.WriteLine("Com um desconto concedido de {0}%, o total a pagar pelo cliente é de: R$ {1:f2}", (fDesc), ((fTotalPagar) - (fTotalPagar * (fDesc / 100))));
  36.             }
  37.  
  38.             return fTotalPagar;
  39.         }
  40.  
  41.         static void Main(string[] args)
  42.         {
  43.             //Entrada de dados
  44.             Console.WriteLine("Informe a descrição do produto: ");
  45.             string sDecricao = Convert.ToString(Console.ReadLine());
  46.  
  47.             Console.WriteLine("Informe a quantidade de produtos adquiridos: ");
  48.             float fQtd = Convert.ToSingle(Console.ReadLine());
  49.  
  50.             Console.WriteLine("Informe o valor unitário do produto: ");
  51.             float fValorUnit = Convert.ToSingle(Console.ReadLine());
  52.  
  53.             //Chama a função, que fará os calculos e saída de dados
  54.             CalcularValorAPagar(fQtd, fValorUnit);
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement