GitHub

Practice

Practice - 019

A program to explain COMPOUND IF (Calculate HRA and DA from Basic Salary)

use text_io::scan;
fn main() {
practice19()
}
fn practice19() {
let bs: f64;
let mut hra: f64 = 0.0;
let mut da: f64 = 0.0;
println!("Enter basic salary: ");
scan!("{}", bs);
if bs >= 5000.0 {
hra = 0.10 * bs;
da = 0.05 * bs;
}
println!("HRA: {}", hra);
println!("DA: {}", da);
}

Config

[package]
name = "practice"
version = "0.1.0"
edition = "2021"
[dependencies]
text_io = "0.1.12"

Result

Enter basic salary:
7500
HRA: 750
DA: 375
Previous
Practice - 018