Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
522 B
2
Indexable
Never
#include <stdio.h>
float inputIncome(){
    float s = -1;
    while (!(s > 0)){
        printf("Input your valid income: ");
        scanf("%f", &s);
    }
    return s;
}
int main()
{
    float s, t; 
    s = inputIncome();
    if (s > 4000){
        t = (s - 4000) * 0.2 + 250;
    } else if (s > 2000){
        t = (s - 2000) * 0.1 + 50;
    } else if (s > 1000){
        t = (s - 1000) * 0.05;
    } else {
        t = 0;
    };
    
    printf("The tax T is %f corresponding to your %f income", t, s);
    return 0;
}