Welcome

>>>Welcome to my "CODE BAZAR"
Code marshal
URI online judge
Others
Code marshal
URI online judge
Others
Code marshal
URI online judge
Others

Update ✔✔✔ Upcoming programming book (.pdf) "Programming Contest (data structures and algorithms) by Md. Mahbub Hasan & "Graph Algorithms" by Safayat Asraf "****** Date: 20 March, 2019****Hazrat Ali****

Sunday, 13 November 2016

URI-1038

URI Online Judge | 1038

Snack

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Problem link Click here
Using the following table, write a program that reads a code and the amount of an item. After, print the value to pay. This is a very simple program with the only intention of practice of selection commands.

Input

The input file contains two integer numbers X and Y. X is the product code and Y is the quantity of this item according to the above table.

Output

The output must be a message "Total: R$ " followed by the total value to be paid, with 2 digits after the decimal point.
Input SampleOutput Sample
3 2Total: R$ 10.00
4 3Total: R$ 6.00
2 3Total: R$ 13.50

Solution...

#include<stdio.h>
int main()
{
    float a=4.00,b=4.50,c=5.00,d=2.00,e=1.50;
    int m,n;
    scanf("%d%d",&m,&n);
    if(m==1){printf("Total: R$ %.2f\n",a*n);}
    else if(m==2){printf("Total: R$ %.2f\n",b*n);}
    else if(m==3){printf("Total: R$ %.2f\n",c*n);}
    else if(m==4){printf("Total: R$ %.2f\n",d*n);}
    else if(m==5){printf("Total: R$ %.2f\n",e*n);}
    return 0;
}

No comments:

Post a Comment