Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int distance;
- String medium;
- int time;
- System.out.println("Please select medium: air, water, or steel");
- medium = scanner.nextLine();
- System.out.println("Please give the distance of a sound wave (in feets)");
- distance = scanner.nextInt();
- switch (medium)
- {
- case "Air":
- case "air":
- time = distance / 1100;
- System.out.println("It will take " + time + " seconds");
- break;
- case "Water":
- case "water":
- time = distance / 4900;
- System.out.println("It will take " + time + " seconds");
- break;
- case "Steel":
- case "steel":
- time = distance / 16400;
- System.out.println("It will take " + time + " seconds");
- break;
- default:
- System.out.println("WRONG MEDIUM");
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment