Write A Program That Requests The Price And Weight Of An Item In Pounds And Ounces, And Then Determines The Price Per Ounce.

Write a program that requests the price and weight of an item in pounds and ounces, and then determines the price per ounce.

So, the Price Per Ounce formula is TOTAL PRICE / OUNCE = PRICE PER OUNCE. I have no idea why the screenshot says another value.

Regardless, heres a simple Lua code for it.

For these kinds of questions, please write the language it is asking.

print("Enter the price of an item:")

price = tonumber( io.read() )

if not price then

 print("Invalid Price")

 return

end

--

print("Enter weight of item in pounds and ounces separately.")

--

print("Enter pounds: ")

pounds = tonumber( io.read() )

if not pounds then

 print("Invalid Pounds")

 return

end

--

print("Enter ounce: ")

ounce = tonumber( io.read() )

if not ounce then

 print("Invalid ounce:")

 return

end

-- CALCULATE

price_per_ounce = price / ounce

-- RETURN

print("------------------")

print("Price per ounce: $" .. price_per_ounce)


Comments

Popular posts from this blog

Magbigay Ng Slogan Na Ang Topic Ay Tungkol Sa Sipag, Tiyaga, Pangarap, Mithiin

Ano Ang Puntong Nais Iparating Ni Isagani Sa Pari?

Talasalitaan , Paalala, Sinalakay, Makita, Lumitaw, Sinakmal