Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧮 Rust CLI Calculator

A blazing-fast, type-safe command-line calculator with CGPA support, random number generation, and formatted output. Built with Rust’s safety guarantees.

Built with Rust CGPA Feature Crates.io

Features (incluing expected)

  • Basic Math: +, -, *, /, %
  • 🎓 CGPA Calculator: Compute semester GPA/CGPA
  • 🎲 Random Numbers: Generate within a range
  • Pretty Output: Colorized results (via std::fmt)
  • 📊 Calculation History: Last 5 operations saved
**Output:**
```text
┌──────────────┬────────┐
│ Course       │ Grade  │
├──────────────┼────────┤
│ 3 credits    │ A      │
│ 4 credits    │ B      │
│ 2 credits    │ D      │
└──────────────┴────────┘
CGPA: 3.54/4.0

🎲 Random Numbers

calc random --min 10 --max 50  # Random integer between 10-50

🏗️ Code Structure

src/
├── cgpa.rs            # CGPA logic (grade mapping, weighted average)
├── operation.rs       # Root arithmetic operations
├── shunting_yard.rs   # Implementation of shunting yard algorithm. Prioritizing PEMDAS
├── shunting_yard/     # Directory for shunting yard operationn
│   └── operation.rs   # Subroot arithmetic operations used in Shunting yard
└── main.rs            # CLI interface

🤝 Contributing

To add features (e.g., SGPA support):

  1. Implement logic in cgpa.rs
  2. Add tests:
    #[test]
    fn test_cgpa_calculation() {
        assert_eq!(calculate_cgpa(&[3, 4], &["A", "B+"]), 3.45);
    }
  3. Submit a PR!

About

A complex CLI rust calculator that explores concept across th rust ecosystem, such as macro_rules!, match, rust complex erro handling as well as modular file structur. future iteraton of the tool would include pushing to crate.io

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages