Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- public class DemoAvFel {
- public static void main(String[] args) {
- int input = JOptionPage.showInputDialog("Skriv in ett tal mellan 1-5, absolut inget annat! ;)");
- int divide = 0;
- switch(input)
- {
- case 1:
- divide = 12;
- break;
- case 2:
- divide = 24;
- break;
- case 3:
- divide = 19;
- break;
- case 4:
- divide = 7;
- break;
- case 5:
- divide = 4;
- break;
- }
- double result = 42.0 / divide;
- JOptionPane.showMessageDialog(null, String.format("Resultatet blev: %.2f", result));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement