Monday, July 04, 2016

URI Online Judge Solution : 1010 Simple Calculate (Beginner Problem)

Posted by LIfe2Coding on Monday, July 04, 2016 in | 2 comments
URI Online Judge | 1010

Simple Calculate

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
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 p1, p1_u, p2, p2_u;
	float p1_price, p2_price;
	float payment;
	
	scanf("%d %d %f %d %d %f", &p1, &p1_u, &p1_price, &p2, &p2_u, &p2_price);
	
	payment = p1_price*p1_u + p2_price*p2_u;

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


	return 0;
}

2 comments:

  1. #include

    int main()
    {

    int A[1], B[1];
    float VALORA, VALORB, TOTAL;


    for(int i =0; i<2; i++){
    scanf("%d", &A[i]);

    }
    scanf("%f", &VALORA);

    for(int i =0; i<2; i++){
    scanf("%d", &B[i]);

    }
    scanf("%f", &VALORB);



    TOTAL = A[1] * VALORA + B[1] * VALORB;

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

    }

    ReplyDelete
  2. #include

    int main()
    {

    int A[1], B[1];
    float VALOR[1], TOTAL;


    for(int i =0; i<2; i++){
    scanf("%d", &A[i]);

    }
    scanf("%f", &VALORA[0]);

    for(int i =0; i<2; i++){
    scanf("%d", &B[i]);

    }
    scanf("%f", &VALOR[1]);



    TOTAL = A[1] * VALORA + B[1] * VALORB;

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

    }

    ReplyDelete