Advertisement
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_9
- {
- class Program
- {
- static float CalcularValorAPagar(float Quantidade, float Valorunit)
- {
- float fTotalPagar = (Quantidade * Valorunit);
- if (Quantidade <= 5.0)
- {
- float fDesc = 2;
- Console.WriteLine("\n{0} itens à um valor unitário de R$ {1:f2} totalizam R$ {2:f2}", Quantidade, Valorunit, fTotalPagar);
- Console.WriteLine("Com um desconto concedido de {0}%, o total a pagar pelo cliente é de: R$ {1:f2}", (fDesc), ((fTotalPagar) - (fTotalPagar * (fDesc / 100))));
- }
- if ((Quantidade > 5.0) && (Quantidade <= 10.0))
- {
- float fDesc = 3;
- Console.WriteLine("\n{0} itens à um valor unitário de R$ {1:f2} totalizam R$ {2:f2}", Quantidade, Valorunit, fTotalPagar);
- Console.WriteLine("Com um desconto concedido de {0}%, o total a pagar pelo cliente é de: R$ {1:f2}", (fDesc), ((fTotalPagar) - (fTotalPagar * (fDesc / 100))));
- }
- if ((Quantidade > 10.0))
- {
- float fDesc = 5;
- Console.WriteLine("\n{0} itens à um valor unitário de R$ {1:f2} totalizam e R$ {2:f2}", Quantidade, Valorunit, fTotalPagar);
- Console.WriteLine("Com um desconto concedido de {0}%, o total a pagar pelo cliente é de: R$ {1:f2}", (fDesc), ((fTotalPagar) - (fTotalPagar * (fDesc / 100))));
- }
- return fTotalPagar;
- }
- static void Main(string[] args)
- {
- //Entrada de dados
- Console.WriteLine("Informe a descrição do produto: ");
- string sDecricao = Convert.ToString(Console.ReadLine());
- Console.WriteLine("Informe a quantidade de produtos adquiridos: ");
- float fQtd = Convert.ToSingle(Console.ReadLine());
- Console.WriteLine("Informe o valor unitário do produto: ");
- float fValorUnit = Convert.ToSingle(Console.ReadLine());
- //Chama a função, que fará os calculos e saída de dados
- CalcularValorAPagar(fQtd, fValorUnit);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement