Algorithm


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

URI Online Judge Problem Details:


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 "R$" symbol. The value must be presented with 2 digits after the point.

 
Input Samples Output 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

 

Code Examples

#1 Code Example with C Programming

Code - C Programming

#include <stdio.h>

int main()
{
 int a, b;
 double c, res;

 scanf("%d %d %lf", &a, &b, &c);
 res = b * c;
 scanf("%d %d %lf", &a, &b, &c);
 res += b * c;
 printf("VALOR A PAGAR: R$ %.2lf\n", res);

 return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
12 1 5.30
16 2 5.10

Output

x
+
cmd
VALOR A PAGAR: R$ 15.50
Advertisements

Demonstration


URI 1010 code in C with array
 
#include
int main()
{
    int p_code[2], p_u[2], i;
    float price[2], pay;
    for(i=0; i<2; i++)
    {
        scanf("%d %d %f",&p_code[i],&p_u[i],&price[i]);
    }
    pay=((price[0]*p_u[0])+(price[1]*p_u[1]));
    printf("VALOR A PAGAR: R$ %.2f\n", pay);
    return 0;
 
}




URI Solution 1010 Simple Calculate Code / URI 1010 Simple Calculate solution in CPP:

#include 
using namespace std;

int main(int argc, char const *argv[])
{
 int a, b;
 double c, res;

 scanf("%d %d %lf", &a, &b, &c);
 res = b * c;
 scanf("%d %d %lf", &a, &b, &c);
 res += b * c;
 printf("VALOR A PAGAR: R$ %.2lf\n", res);

 return 0;
}
 
 
 

URI Solution 1010 Simple Calculate Code / URI 1010 Simple Calculate solution in Java:

import java.util.Scanner;


public class Main{

 public static void main(String[] args) {
  
  int a, b;
  double c, res;
  Scanner sc = new Scanner(System.in);
  
  a = sc.nextInt();
  b = sc.nextInt();
  c = sc.nextDouble();
  res = b * c;
  
  a = sc.nextInt();
  b = sc.nextInt();
  c = sc.nextDouble();
  res += b * c;
  System.out.printf("VALOR A PAGAR: R$ %.2f\n", res);
  
  
 }

}


URI Solution 1010 Code / URI 1010 solution in  Python:

linha1 = input().split(" ")
linha2 = input().split(" ")

cod1, qtde1, valor1 = linha1
cod2, qtde2, valor2 = linha2

total = (int(qtde1) * float(valor1)) + (int(qtde2) * float(valor2))

print("VALOR A PAGAR: R$ %0.2f" %total)
 
 

URI Solution 1010 Code / URI 1010 solution in  C# (C Sharp):


URI Online Judge Solution 1010 Code Demonstration:

First take 3 values in store it in a result variable
Again take 3 value and now just increment the result variable. And solved, in C that is

        scanf("%d %d %lf", &a, &b, &c);
 res = b * c;
 scanf("%d %d %lf", &a, &b, &c);
 res += b * c;

 

Previous
#1009 - Beecrowd Online Judge Solution 1009 - Salary with bonus - Solution in C, C++, Java, Python, C#
Next
#1011 Beecrowd Online Judge Solution 1011 Sphere Solution in C, C++, Java, Python and C#