Tuesday 26 January 2016

Solution of URI 1038 :: Snack


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 X,Y;
    double A;
    scanf ("%d%d",&X,&Y);
    if(X==1)
    {
        A=Y*4.00;
        printf("Total: R$ %.2lf\n",A);
    }
    else if(X==2)
    {
        A=Y*4.50;
        printf("Total: R$ %.2lf\n",A);
    }
    else if(X==3)
    {
        A=Y*5.00;
        printf("Total: R$ %.2lf\n",A);
    }
    else if(X==4)
    {
        A=Y*2.00;
        printf("Total: R$ %.2lf\n",A);
    }
    else if(X==5)
    {
        A=Y*1.50;
        printf("Total: R$ %.2lf\n",A);
    }
    return 0;
}

1 comment:

  1. hello, Aminul!

    this is my code:

    #include

    int main(void){
    double order;
    int code, qntd;
    printf("Informe o codigo do item e a quantidade.\n");
    scanf("%i %i", &code, &qntd);

    switch(code){
    case 1: order = qntd * 4.00; break;
    case 2: order = qntd * 4.50; break;
    case 3: order = qntd * 5.00; break;
    case 4: order = qntd * 2.00; break;
    case 5: order = qntd * 1.50; break;
    default: printf("Codigo Invalido!\n");
    }

    printf("Total: R$ %.2f\n", order);

    return 0;
    }


    i have tested all entrances and exits but still with wrong answer(60%).

    ReplyDelete

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