add basic working prototype

This commit is contained in:
mollusk 2018-12-31 07:24:04 -07:00
commit 9b14a82de5
2 changed files with 72 additions and 0 deletions

6
Project.toml Normal file
View File

@ -0,0 +1,6 @@
authors = ["mollusk <silvernode@gmail.com>"]
name = "BillCalc"
uuid = "40176720-0cca-11e9-2394-e19ce8dd2e58"
version = "0.1.0"
[deps]

66
src/BillCalc.jl Normal file
View File

@ -0,0 +1,66 @@
module BillCalc
using Printf
householdSize = 3::Int64 # the amount of people to divide by
function splitCost(bill::Float64, peopleAmount::Int64)
total = bill / peopleAmount
return print("$(@sprintf("%.2f", total))\n")
end
print("Enter Total Cost of Water Bill: ")
waterBill = chomp(readline())
waterBill = lstrip(waterBill, ['.', '@', '#', '$', '%', '^', '&', '*', '(', ')',
'-','+', '-', '+', '{', '}', '[', ']', '|',
':', ';', '<', '>', ',', '?', '/', '!', '~', '`'])
println(waterBill);exit(0)
if occursin(r"[0-9]","$waterBill") != true
println("Please enter a number.")
exit(1)
end
waterBill = tryparse(Float64, waterBill)
print("Enter Total Cost of Gas Bill: ")
gasBill = readline()
if occursin(r"[0-9]","$gasBill") != true
println("Please enter a number.")
exit(1)
end
gasBill = tryparse(Float64, gasBill)
print("Enter Total Cost of Internet Bill: ")
internetBill = readline()
if occursin(r"[0-9]","$internetBill") != true
println("Please enter a number.")
exit(1)
end
internetBill = tryparse(Float64, internetBill)
print("Enter Total Cost of Electric Bill: ")
electricBill = readline()
if occursin(r"[0-9]","$electricBill") != true
println("Please enter a number.")
exit(1)
end
electricBill = tryparse(Float64, electricBill)
println("-----------------------------------")
println("Cost Per Person")
println("-----------------------------------")
print("Water: ", '$'); splitCost(waterBill, householdSize)
print("Gas: ", '$'); splitCost(gasBill, householdSize)
print("Internet: ", '$'); splitCost(internetBill, householdSize)
print("Electric: ", '$'); splitCost(electricBill, householdSize)
end # module