add basic working prototype
This commit is contained in:
commit
9b14a82de5
6
Project.toml
Normal file
6
Project.toml
Normal 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
66
src/BillCalc.jl
Normal 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
|
Loading…
x
Reference in New Issue
Block a user