Week 17
Source Code
local myName = ""
print("Name: " .. myName)
-- define main function
function main()
print("Main Function")
local done = false
local choice = nil
while not done do
print("Menu")
print("E1 - Example 1")
print("Q - Quit")
io.write("Choice: ")
choice = io.read()
if choice == "E1" then
-- call Example 1 Function
elseif choice == "E2" then
-- call Example 2 Function
elseif choice == "E3" then
-- call Example 3 Function
elseif choice == "E4" then
-- call Example 4 Function
elseif choice == "E5" then
-- call Example 5 Function
elseif choice == "E6" then
-- call Example 6 Function
elseif choice == "E7" then
-- call Example 7 Function
elseif choice == "Q" then
done = true
else
print("Invalid Choice")
end
end
end
-- define Example 1 Function
-- define Example 2 Function
-- define Example 3 Function
-- define Example 4 Function
-- define Example 5 Function
-- define Example 6 Function
-- define Example 7 Function
-- call main function
main()
w17problem1.lua
-- main function
function main()
-- call problem1 function
end
-- problem1 function definition
-- call to main function
main()
w17problem2.lua
-- main function
function main()
-- call problem2 function
end
-- problem2 function definition
-- call to main function
main()
w17problem3.lua
-- main function
function main()
-- call problem3 function
end
-- problem3 function definition
-- call to main function
main()
w17problem4.lua
-- main function
function main()
-- call problem4 function
end
-- problem4 function definition
-- call to main function
main()
w17problem5.lua
-- main function
function main()
-- call problem5 function
end
-- problem5 function definition
-- call to main function
main()
w17problem6.lua
-- main function
function main()
-- call problem6 function
end
-- problem6 function definition
-- call to main function
main()
w17problem7.lua
-- main function
function main()
-- call problem7 function
end
-- problem7 function definition
-- call to main function
main()
w17problem8.lua
-- main function
function main()
-- call problem8 function
end
-- problem8 function definition
-- call to main function
main()
w17problem9.lua
-- main function
function main()
-- call problem9 function
end
-- problem9 function definition
-- call to main function
main()
project2.lua
-- Main Function
function main()
print("College Cost Project")
local done = false
local choice = nil
while not done do
print("Menu")
print("C1 - Public College") -- replace with the name of your public college
print("C2 - Private College") -- replace with the name of your private college
print("L - Loan Calculator")
print("Q - Quit")
io.write("Choice: ")
choice = io.read()
if choice == "C1" then
-- call the tuition, housing and meals functions
elseif choice == "C2" then
-- call the tuition, housing and meals functions
elseif choice == "L" then
elseif choice == "Q" then
done = true
else
print("Invalid Choice")
end
end
end
-- define public tuition function
function public_tuition()
end
-- define public housing function
function public_housing()
end
-- define public meals function
function public_meals()
end
-- define private tuition function
function private_tuition()
end
-- define private housing function
function private_housing()
end
-- define private meals function
function private_meals()
end
-- define loan calculator Function
function loanCalculator()
end
-- call main function
main()
Last updated
Was this helpful?