// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.0 <0.9.0;
contract Artithmetic{
uint256 yearlySalary = 250000 ;
uint256 months = 12;
uint256 conversionRate = 113;
uint256 public monthlySalary = yearlySalary / months * conversionRate;
string public message = "Import a 2021 Audi A6";
bool public youreRich = true;
function updateYearlySalary(uint256 _yearlySalary) public{
yearlySalary = _yearlySalary;
}
function financialAdvice() public {
if(monthlySalary<=2000000){
youreRich = false;
message = "Buy assets that earn you passive income first!";
}
}}
I can't get the code to perform arithmetic that would change the financial advice based on the amount I input when I compile.
You should write an additional function to set the monthly salary
uint256 public monthlySalary;
function setMonthlySalary() public {
monthlySalary= yearlySalary / months * conversionRate;
}
Update yearly salary first. call updateYearlySalary
then call setMonthlySalary
then call financialAdvice
Finally call message
and it will be updated: