create procs for cpm and options
This commit is contained in:
parent
4ff6e01337
commit
0341ba3a45
103
src/stockers.nim
103
src/stockers.nim
@ -3,39 +3,92 @@ import regex
|
||||
import strformat
|
||||
|
||||
when isMainModule:
|
||||
var acases: float
|
||||
var aminutes: float
|
||||
var name: string
|
||||
var time_tail = "hours"
|
||||
|
||||
stdout.write("Name of employee: ")
|
||||
name = readLine(stdin)
|
||||
proc casesPerMinute(name: string): string =
|
||||
var acases: float
|
||||
var aminutes: float
|
||||
|
||||
stdout.write("Number of cases: ")
|
||||
var cases = readLine(stdin)
|
||||
#stdout.write("Name of employee: ")
|
||||
#name = readLine(stdin)
|
||||
|
||||
stdout.write(fmt"Number of cases for {name}: ")
|
||||
var cases = readLine(stdin)
|
||||
|
||||
|
||||
if re"[^0-9.]" in cases:
|
||||
echo "I can't do math on words, fucking moron"
|
||||
quit(1)
|
||||
else:
|
||||
acases = cases.parseFloat()
|
||||
if cases == "q":
|
||||
quit(0)
|
||||
|
||||
if re"[^0-9.]" in cases:
|
||||
echo "I can't do math on words, fucking moron"
|
||||
quit(1)
|
||||
else:
|
||||
acases = cases.parseFloat()
|
||||
|
||||
stdout.write("Number of minutes it took: ")
|
||||
var minutes = readLine(stdin)
|
||||
stdout.write(fmt"Number of hours or minutes it took: ")
|
||||
var minutes = readLine(stdin)
|
||||
|
||||
if re"[^0-9.]" in minutes:
|
||||
echo "I can't do math on words, fucking moron"
|
||||
quit(1)
|
||||
else:
|
||||
aminutes = minutes.parseFloat()
|
||||
if aminutes < 10:
|
||||
aminutes = aminutes * 60
|
||||
if minutes == "q":
|
||||
quit(0)
|
||||
|
||||
if re"[^0-9.]" in minutes:
|
||||
echo "I can't do math on words, fucking moron"
|
||||
quit(1)
|
||||
else:
|
||||
aminutes = minutes.parseFloat()
|
||||
if aminutes < 10:
|
||||
aminutes = aminutes * 60
|
||||
|
||||
|
||||
|
||||
let cpm: float = acases / aminutes
|
||||
let cpm: float = acases / aminutes
|
||||
|
||||
|
||||
echo(fmt"{name} can throw: {cpm:2.2f} cases per minute")
|
||||
return(fmt"{name} can throw: {cpm:2.2f} cases per minute")
|
||||
|
||||
|
||||
|
||||
|
||||
proc options(name: string) =
|
||||
echo(fmt"""
|
||||
Properties of {name}
|
||||
|
||||
|
||||
1) Cases per minute
|
||||
q) Quit
|
||||
|
||||
""")
|
||||
|
||||
stdout.write("Choose a property: ")
|
||||
var property = readLine(stdin)
|
||||
|
||||
if property == "1":
|
||||
echo(casesPerMinute(name))
|
||||
quit(0)
|
||||
else:
|
||||
echo("That is not a property")
|
||||
|
||||
|
||||
proc mainScreen() =
|
||||
echo("""
|
||||
|
||||
|
||||
1) Leroy
|
||||
2) Perez
|
||||
3) Eric
|
||||
4) Emiliano
|
||||
5) Jamal
|
||||
6) Joseph
|
||||
7) Justin
|
||||
8) Lee
|
||||
q) Quit
|
||||
|
||||
""")
|
||||
|
||||
stdout.write("Choose an employee: ")
|
||||
var employee = readLine(stdin)
|
||||
|
||||
if employee == "1":
|
||||
options("Leroy")
|
||||
elif employee == "q":
|
||||
quit(0)
|
||||
|
||||
mainScreen()
|
Loading…
x
Reference in New Issue
Block a user