Added rust to practice
This commit is contained in:
1
rust/calculator/.gitignore
vendored
Normal file
1
rust/calculator/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
target
|
4
rust/calculator/Cargo.lock
generated
Normal file
4
rust/calculator/Cargo.lock
generated
Normal file
@@ -0,0 +1,4 @@
|
||||
[root]
|
||||
name = "calculator"
|
||||
version = "0.1.0"
|
||||
|
6
rust/calculator/Cargo.toml
Normal file
6
rust/calculator/Cargo.toml
Normal file
@@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "calculator"
|
||||
version = "0.1.0"
|
||||
authors = ["Logen Kain <logen@sudotask.com>"]
|
||||
|
||||
[dependencies]
|
35
rust/calculator/src/main.rs
Normal file
35
rust/calculator/src/main.rs
Normal 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);
|
||||
}
|
Reference in New Issue
Block a user