[example] Simple interest calculation.

This commit is contained in:
Alessandro Coglio 2022-08-03 14:47:26 -07:00 committed by Pranav Gaddamadugu
parent 754a3ce685
commit 123aa2822c
5 changed files with 32 additions and 0 deletions

2
examples/interest/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
outputs/
build/

View File

@ -0,0 +1,8 @@
# interest.aleo
## Build Guide
To compile this Aleo program, run:
```bash
aleo build
```

View File

@ -0,0 +1,4 @@
// The program input for interest/src/main.leo
[main]
capital: u32 = 80u32;
rate: u32 = 5u32; // 5%

View File

@ -0,0 +1,10 @@
{
"program": "interest.aleo",
"version": "0.0.0",
"description": "",
"development": {
"private_key": "APrivateKey1zkp6QSDYHfL4Tr54dKXXxSwZWVpm1Ro3feYgpvAampgNmKu",
"address": "aleo1lwxu6nluvjt6hu0gurjsph23wlvyxkut59r757szma2s9mrljggsvue3n4"
},
"license": "MIT"
}

View File

@ -0,0 +1,8 @@
// The 'interest' main function.
function main(capital: u32, public rate: u32) -> u32 {
let amount: u32 = capital;
for i:u8 in 0u8..10u8 { // accrue for 10 periods
amount += amount * rate / 100u32; // round down
}
return amount;
}