use serde::{ Deserialize, Serialize };
use serde_json::Result;
fn round_to_two_decimal_places (float_1 : f64) -> String {
format! ("{:.2}", float_1)
}
pub struct Proceeds {
pub every__f64: f64,
pub every__string: String,
}
pub fn likelihood (
name : &str,
has : i64,
realities : i64
) -> Proceeds {
let found_realities_f64 : f64 = 1 as f64 / (has as f64 / realities as f64);
let found_realities_string : String = round_to_two_decimal_places (found_realities_f64);
let percent_f64 : f64 = (has as f64 / realities as f64) * 100 as f64;
let percent_string : String = round_to_two_decimal_places (percent_f64);
let ratio_string : String = round_to_two_decimal_places (0 as f64);
let odds_2_f64 : f64 = (realities as f64 - has as f64) / has as f64;
let odds_2_string : String = round_to_two_decimal_places (odds_2_f64);
#[derive(Serialize, Deserialize)]
struct Show_Results {
every__f64 : f64,
every__string : String,
VD_odds: String,
percent: String,
fraction_unreduced: String
};
let show_results = Show_Results {
every__f64: found_realities_f64,
every__string: format! ("{}", found_realities_string),
VD_odds: format! ("1 : {}", odds_2_string),
percent: format! ("{}%", percent_string),
fraction_unreduced : format! ("{} / {}", has, realities)
};
let results_hull = serde_json::to_string_pretty (&show_results).unwrap ();
println! ("{}: {}", name, results_hull);
Proceeds {
every__f64: found_realities_f64,
every__string: found_realities_string,
}
}