Thursday 14 January 2016

Solution of URI 1985 :: MacPRONALTS


Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.

/**Bismillahir Rahmanir Rahim.**/

#include <stdio.h>
int main()
{
    int tst;
    double price;
    double amount = 0.00;
    int code, quantity;
    scanf("%d", &tst);
    while(tst--)
    {
        scanf("%d %d", &code, &quantity);
        if(code==1001)
            amount += (double) quantity*1.50;
        else if(code==1002)
                amount += (double) quantity*2.50;
        else if(code==1003)
                amount += (double) quantity*3.50;
        else if(code==1004)
                amount += (double) quantity*4.50;
        else if(code==1005)
                amount += (double) quantity*5.50;
    }
    printf("%.2lf\n", amount);
    return 0;
}

1 comment:

Note: only a member of this blog may post a comment.