URI Online Judge | 1010 Simple Calculate (Solution)

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


URI Online Judge | 1010

Simple Calculate

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
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 InputsSample 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 <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;
}

Comments

  1. This comment has been removed by the author.

    ReplyDelete
  2. #include
    int main()

    {

    int number,unit,number2,unit2;

    float price,price2,payment;

    scanf("%d %d %f",&number,&unit,&price);
    scanf("%d %d %f",&number2,&unit2,&price2);

    printf("VALOR A PAGAR: R$ %.2f\n",payment=(unit*price)+(unit2*price2));

    return 0;

    }

    ReplyDelete
  3. #include
    int main()
    {
    int c1,u1,c2,u2;
    float p1,p2,t;
    scanf("%d %d %f",&c1,&u1,&p1);
    scanf("%d %d %f",&c2,&u2,&p2);
    t=(u1*p1)+(u2*p2);
    printf("VALOR A PAGAR: R$ = %0.2f\n",t);
    return 0;
    }



    where is my wrong??

    ReplyDelete
    Replies
    1. #include
      int main ()
      {
      int a,b,c,d;
      float e,f,result;
      scanf("%d %d %.2f\n",&a,&b,&e);
      scanf("%d %d %.2f\n",&c,&d,&f);
      result=(b*e)+(d*f);
      printf("VALOR A PAGAR: R$ %.2f",result);
      }

      Delete
  4. #include
    int main ()
    {
    int a,b,c,d;
    float e,f,result;
    scanf("%d %d %f",&a,&b,&e);
    scanf("%d %d %f",&c,&d,&f);
    result=(b*e)+(d*f);
    printf("VALOR A PAGAR: R$ %.2f",result);
    }

    ReplyDelete

Post a Comment

Popular posts from this blog

URI Online Judge | 1036 Bhaskara's Formula (Solution)

URI Online Judge | 1041 Coordinates of a Point (Solution)

URI Online Judge | 1042 Simple Sort (Solution)