Created
January 26, 2023 17:27
-
-
Save ArslanKathia/2e81da92b957d0a6a7d8b13d5dcd088f to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8; | |
| contract ifElse{ | |
| //we can't use if and else on contract level | |
| function func(uint _x) public pure returns(string memory){ | |
| string memory val; | |
| if(_x>100){ | |
| val = "value greater than 100"; | |
| } | |
| else if(_x<100){ | |
| val = "value smaller than 100"; | |
| }else{ | |
| val = "value equal to 100"; | |
| } | |
| return val; | |
| } | |
| function subjectResult(uint _marks) public pure returns(string memory){ | |
| string memory result; | |
| if(_marks>=90 && _marks<=100){ | |
| result = "Your Subject GPA is 4"; | |
| }else if(_marks<90 && _marks>=85){ | |
| result = "your subject gpa is 3.7"; | |
| }else if(_marks<85 && _marks>=80){ | |
| result = "your subject gpa is 3.3"; | |
| }else if(_marks<80 && _marks>=75){ | |
| result = "your subject gpa is 3"; | |
| }else if(_marks<75 && _marks>=70){ | |
| result = "your subject gpa is 2.7"; | |
| }else if(_marks<70 && _marks>=65){ | |
| result = "your subject gpa is 2.3"; | |
| }else if(_marks<65 && _marks>50){ | |
| result = "your subject gpa is 2"; | |
| }else if(_marks <=50){ | |
| result = "your subject is failed"; | |
| }else if(_marks >100){ | |
| result = "your entered invalid marks"; | |
| } | |
| return result; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment