Solve of URI 1010 (Simple Calculate) in C & C++
Problem Description of URI Online Judge 1010:
Problem number: 1010.Problem name: Simple Calculate.Problem level: 3.Problem category: Beginner.Points: 3.1 pointsBase time limit: 1 second.Memory limit: 200 MB.Problem subject: Sequential.Problem adapted by: Neilor Tonin (Brazil).Link: https://www.urionlinejudge.com.br/judge/en/problems/view/1010Solution language: C & C++My profile: https://www.urionlinejudge.com.br/judge/en/profile/38770
Problem name: Simple Calculate.
Problem level: 3.
Problem category: Beginner.
Points: 3.1 points
Base time limit: 1 second.
Memory limit: 200 MB.
Problem subject: Sequential.
Problem adapted by: Neilor Tonin (Brazil).
Link: https://www.urionlinejudge.com.br/judge/en/problems/view/1010
Solution language: C & C++
My profile: https://www.urionlinejudge.com.br/judge/en/profile/38770
Solution in C:
//URI online judge 1010 solution in C//This solution is made by Mehedi Hasan Kajol
#include<stdio.h>
int main(void){
int code1, quantity1, code2, quantity2;
double price1, price2, result1, result2, result;
scanf(" %d %d %lf", &code1, &quantity1, &price1);
scanf(" %d %d %lf", &code2, &quantity2, &price2);
result1 = (double)quantity1 * price1; //Type cast int to double
result2 = (double)quantity2 * price2; //Type cast int to double
result = result1 + result2; //Adding two product prices.
printf("VALOR A PAGAR: R$ %.2lf\n",result);
return 0;
}
Solution in C++:
//URI online judge 1010 solution in C++
//This solution is made by Mehedi Hasan Kajol
#include<iostream>
using namespace std;
int main(void){
int code1, quantity1, code2, quantity2;
double price1, price2, result1, result2, result;
cin>> code1>> quantity1>> price1;
cin>> code2>> quantity2>> price2;
result1 = (double)quantity1 * price1; //Type cast int to double
result2 = (double)quantity2 * price2; //Type cast int to double
result = result1 + result2; //Adding two product prices.
printf("VALOR A PAGAR: R$ %.2lf\n",result); //printf() for precision.
return 0;
}