Added rust to practice

This commit is contained in:
2017-04-11 16:17:19 -07:00
parent f6a827b078
commit 2a38448585
9 changed files with 162 additions and 5 deletions

1
rust/calculator/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
target

4
rust/calculator/Cargo.lock generated Normal file
View File

@@ -0,0 +1,4 @@
[root]
name = "calculator"
version = "0.1.0"

View File

@@ -0,0 +1,6 @@
[package]
name = "calculator"
version = "0.1.0"
authors = ["Logen Kain <logen@sudotask.com>"]
[dependencies]

View File

@@ -0,0 +1,35 @@
/*
* Create a simple calculator
* I should be able to do basic add/sub/mult/divd and be able to use "()"
*
* 1. Take user input
* a. Check to see if there is a previous answer that we are going to act on
* 1. initialize answer to 0
* 2. if the user starts with an operand, the first number is "answer"
* else, start a new problem with whatever the user puts in
* b. Parse user input for ( ) / * - + in order to formulate a proper math problem
* 1. Strip trailing and leading white space
* 2. Check to see if there is a library that converts a string to a math problem
* c. check for the clear command
* 2. Calculate the answer
* a. Take
* 3. return the answer above a new prompt in a clered screen
*
*
*/
fn main() {
let strNumber1;
let strNumber2;
let number: i32;
strNumber1 = "5";
strNumber2 = "6";
number = strNumber1.parse::<i32>().unwrap() + strNumber2.parse::<i32>().unwrap();
//let my_int = number.parse::<i32>().unwrap();
println!("Hello, world! Here's your number! {}", number);
}