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****

Thursday, 10 November 2016

Uri-1010

URI Online Judge | 1010

Simple Calculate

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Problem link Click here
In this problem, the task is to read a code of a product 1, the number of units of product 1, the price for one unit of product 1, the code of a product 2, the number of units of product 2 and the price for one unit of product 2. After this, calculate and show the amount to be paid.

Input

The input file contains two lines of data.\ In each line there will be 3 values: two integers and a floating value with 2 digits after the decimal point.

Output

The output file must be a message like the following example where "Valor a pagar" means Value to Pay. Remember the space after ":" and after "$" symbol. The value must be presented with 2 digits after the point.
Input SamplesOutput Samples
12 1 5.30
16 2 5.10
VALOR A PAGAR: R$ 15.50
13 2 15.30
161 4 5.20
VALOR A PAGAR: R$ 51.40
1 1 15.10
2 1 15.10
VALOR A PAGAR: R$ 30.20

Solution.....

#include <stdio.h>
int main(){

    int p_code,p_unit[2],i;
    float price[2],total;
    for(i=0;i<2;i++){
        scanf("%d %d %f",&p_code,&p_unit[i],&price[i]);
    }
    total=((p_unit[0]*price[0])+(p_unit[1]*price[1]));

    printf("VALOR A PAGAR: R$ %.2f\n",total);

    return 0;
}

No comments:

Post a Comment