URI ONLINE JUDGE SOLUTION 1038 - Snack

Problem


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.


Solution
#include<stdio.h>
int main()
{
    int x,y;
    double total = 0.0;
    scanf("%d%d",&x,&y);
    if(x == 1){
        total = y*4.0;
    }
    if(x == 2){
        total = y*4.5;
    }
    if(x == 3){
        total = y*5.0;
    }
    if(x == 4){
        total = y*2.0;
    }
    if(x == 5){
        total = y*1.5;
    }
    printf("Total: R$ %0.2lf\n",total);
    return 0;

}

Solution Tricks:Suppose,There are given a product list and their price.You have to find your buying cost with programming.At first you have to take two user input one for which product he bought and other for it's quantity.Now multiply it with it's price and show the cost in a message.That's it.Simple program.Show the code and try yourself.

Comments

Popular posts from this blog

URI ONLINE JUDGE SOLUTION 1021 - Banknotes and Coins

URI ONLINE JUDGE SOLUTION 1040 - Average 3

URI ONLINE JUDGE SOLUTION 1036 - Bhaskara's Formula