URI Online Judge | 1038 Snack (Solution)

Problem Link:
https://www.urionlinejudge.com.br/judge/en/problems/view/1038

URI Online Judge | 1038

Snack

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Using the following table, write a program that reads a code and a 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 Yis 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.
Sample InputSample Output
3 2Total: R$ 10.00
4 3Total: R$ 6.00
2 3Total: R$ 13.50
Solution:
#include<stdio.h>
int main()
{
    int x,y;
    scanf("%d %d",&x,&y);
    switch(x)
    {
    case 1 :
        printf("Total: R$ %.2lf\n",y*4.0);
        break;
    case 2 :
        printf("Total: R$ %.2lf\n",y*4.50);
        break;
    case 3 :
        printf("Total: R$ %.2lf\n",y*5.0);
        break;
    case 4 :
        printf("Total: R$ %.2lf\n",y*2.0);
        break;
    case 5 :
        printf("Total: R$ %.2lf\n",y*1.50);
        break;
    }
    return 0;
}

Comments

Post a Comment

Popular posts from this blog

URI Online Judge | 1041 Coordinates of a Point (Solution)

URI Online Judge | 1021 Banknotes and Coins (Solution)

URI Online Judge | 1036 Bhaskara's Formula (Solution)