A preserved archive of the Logical Gamers community forums, 2009-2025. The original threads and posts, served read-only. Registration, posting and private messages are gone for good.

Do it!

1.1k views · started by Taz ·
#1
Do it!
This one isnt my homework but its in my book and im finding it hard so i want to see you guys do it.
Who ever does it first gets rep i guess.
Also make itnot case sensitive and use java lol. Use JOptionPane if you want but it would be better for me.

The problem is :

 Write a program that asks the user to enter "air", "water", or "steel", and the distance that a sound wave will travel in the medium. The program should then display the amount of time it will take. You can calculate the amount of time it takes sound to travel in air with the following formula:

Time = Distance/1,100

You can calculate the amount of time it takes sound to travel in water with the following formula:

Time = Distance/4,900

You can calculate the amount of time it takes sound to travel in steel with the following formula:

Time = Distance/16,400
#2
Global $sInput = ""
Global $iDistance = 0

$sInput = InputBox("Taz", "Enter 'air', 'water' or 'steel' as input for our assessment.")
$iDistance = InputBox("Taz", "Enter the distance a sound wave will travel throughout " & $sInput & '.')

Switch $sInput
Case "air"
MsgBox(0, "", $iDistance / 1100)
Case "water"
MsgBox(0, "", $iDistance / 4900)
Case "steel"
MsgBox(0, "", $iDistance / 16400)
Case Else
ConsoleWrite("Invalid input provided!" & @CRLF)
EndSwitch


Slapped that together in AutoIt. Can't use anything else right now. Should work. Just port it to Java. Simple enough.