1
I’m trying to do the following exercise:
10)A fruit plant is selling fruit with the following price list:
Até 5 Kg Acima de 5 Kg Morango R$ 2,50 por Kg R$ 2,20 por Kg Maçã R$ 1,80 por Kg R$ 1,50 por Kg
If the customer buys more than 8 kg in fruit or the total purchase amount exceed R$ 25,00, you will also receive a 10% discount on this total. Write an algorithm to read the amount (in kg) of strawberries and the amount (in kg) of apples purchased and write the value to be paid by the customer.
I wrote the first part of the code but it’s returning R$0,00 when testing, what mistake I made? how can I fix?
#include<stdio.h>
#include<stdlib.h>
main()
{
float qmor,qmac,totalfru,valormor,valormac,valortotal;
printf ("Quantidade de Morangos(Kg):");
scanf ("%f",&qmor);
printf ("Quantidade de Macas(Kg):");
scanf ("%f",&qmac);
totalfru=qmor+qmac;
valortotal=valormor+valormac;
if (qmor<=5)
{
valormor=2.50*qmor;
}
else
{
valormor=2.20*qmor;
}
if (qmac<=5)
{
valormac=1.80*qmac;
}
else
{
valormac=1.50*qmac;
}
printf ("Valor Total: R$%.2f",valortotal);
}
thank you very much!
– Newton Sandey