Data update
This commit is contained in:
parent
72eb4943cb
commit
4d5544505c
2347 changed files with 62432 additions and 16731 deletions
15
Task/Currency/Ballerina/currency.ballerina
Normal file
15
Task/Currency/Ballerina/currency.ballerina
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import ballerina/io;
|
||||
|
||||
public function main() {
|
||||
decimal hamburgers = 4000000000000000;
|
||||
decimal milkshakes = 2;
|
||||
decimal price1 = 5.5;
|
||||
decimal price2 = 2.86;
|
||||
decimal taxPc = 0.0765;
|
||||
decimal totalPreTax = hamburgers * price1 + milkshakes * price2;
|
||||
decimal totalTax = taxPc * totalPreTax;
|
||||
decimal totalAfterTax = totalPreTax + totalTax;
|
||||
io:println("Total price before tax : ", totalPreTax.round(2));
|
||||
io:println("Tax : ", totalTax.round(2));
|
||||
io:println("Total price after tax : ", totalAfterTax.round(2));
|
||||
}
|
||||
21
Task/Currency/C++/currency.cpp
Normal file
21
Task/Currency/C++/currency.cpp
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#include <gmpxx.h>
|
||||
|
||||
struct menu_entry {
|
||||
mpz_class amount;
|
||||
std::string name;
|
||||
mpf_class price;
|
||||
};
|
||||
|
||||
int main() {
|
||||
menu_entry menu[] = { 4000000000000000, "hamburgers", 5.50,
|
||||
2, "milkshakes", 2.86 };
|
||||
mpf_class taxRate;
|
||||
taxRate.set_str("0.0765", 10);
|
||||
mpf_class total = 0;
|
||||
for (menu_entry i : menu)
|
||||
total += i.price * i.amount;
|
||||
gmp_printf("total: €%.2Ff\n", total.get_mpf_t());
|
||||
mpf_class tax = total * taxRate;
|
||||
gmp_printf("tax: €%.2Ff\n", tax.get_mpf_t());
|
||||
gmp_printf("total+tax: €%.2Ff\n", mpf_class{total+tax}.get_mpf_t());
|
||||
}
|
||||
|
|
@ -5,7 +5,6 @@ var milkshakes = BigRat.two
|
|||
var price1 = BigRat.fromFloat(5.5)
|
||||
var price2 = BigRat.fromFloat(2.86)
|
||||
var taxPc = BigRat.fromFloat(0.0765)
|
||||
var totalPc = BigRat.fromFloat(1.0765)
|
||||
var totalPreTax = hamburgers*price1 + milkshakes*price2
|
||||
var totalTax = taxPc * totalPreTax
|
||||
var totalAfterTax = totalPreTax + totalTax
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue