Task 6-Tax - Solution
The task is solved by the user first entering the value of the salary in RSD. This value is then converted into euros using data in the euro exchange rate (117).
Using the if-else command, it is checked whether the salary in euros is higher than 1000. If it is in the formula for calculating the tax, the value 0.2 = 20.0 / 100 * salary EUR is used (20% is tax), and if not then 0.15 (15.0 / 100 * salaryEUR).
Solution:
Using the if-else command, it is checked whether the salary in euros is higher than 1000. If it is in the formula for calculating the tax, the value 0.2 = 20.0 / 100 * salary EUR is used (20% is tax), and if not then 0.15 (15.0 / 100 * salaryEUR).
Solution:
#include <stdio.h>
#include <stdlib.h>
int main()
{
double salaryRSD,salaryEUR,tax,exchangeRate;
exchangeRate=117.0;
printf("Enter the salary in RSD\n");
scanf("%lf",&salaryRSD);
/*calculate salary in euros*/
salaryEUR=salaryRSD/exchangeRate;
//Check if whether the salary is higher than 100 EUR
if(salaryEUR>=1000)
{
tax=0.2*salaryEUR; //If yes tax is (20.0 / 100) * salary
}
else
{
tax=0.15*salaryEUR; //If not tax is (15.0 / 100) * salary
}
printf("Tax is %.2f\n",tax);
return 0;
}
#include <stdlib.h>
int main()
{
double salaryRSD,salaryEUR,tax,exchangeRate;
exchangeRate=117.0;
printf("Enter the salary in RSD\n");
scanf("%lf",&salaryRSD);
/*calculate salary in euros*/
salaryEUR=salaryRSD/exchangeRate;
//Check if whether the salary is higher than 100 EUR
if(salaryEUR>=1000)
{
tax=0.2*salaryEUR; //If yes tax is (20.0 / 100) * salary
}
else
{
tax=0.15*salaryEUR; //If not tax is (15.0 / 100) * salary
}
printf("Tax is %.2f\n",tax);
return 0;
}