[URI Online Judge] – 1010 – Simple Calculate

In this problem the task is read a code for a product 1, the number of units of product 1, the price for one unit of product 1, the code for a product 2, the number of units of product 2, the price for one unit of product 2 and calculates and print the amount to be paid.

Input

The input file contains two lines of data. In each contains 3 numbers: two integers and a floating number with 2 digits after the decimal point.

Output

The output file will contain a message like the following example where “Valor a pagar” means Value to Pay. Remember the space after the “:” and after the “$” symbol. The value must be printed with 2 digits after the point.

Sample Inputs Sample Outputs
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 <cstdio>
#include <cmath>

int main(){
int a, b;
float c, s = 0.0;
while(scanf(“%d %d %f”, &a, &b, &c) != EOF){
s += c * b;
}
printf(“VALOR A PAGAR: R$ %.2f\n”, s);
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s