Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication9;
- import java.util.Scanner;
- /**
- *
- * @author salte02
- */
- public class JavaApplication9 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int val;
- boolean fortsätt = true;
- double radie = 0,
- längd = 0,
- bredd = 0,
- höjd = 0,
- volym = 0;
- final double PI = 3.14159;
- do {
- System.out.println("MENY");
- System.out.println("1. Klot");
- System.out.println("2. Rätblock");
- System.out.println("3. Cylinder");
- System.out.println("4. Avsluta");
- val = input.nextInt();
- switch(val)
- {
- case 1:
- System.out.print("Ange radie: ");
- radie = input.nextDouble();
- volym = 4 * PI * radie * radie * radie / 3;
- break;
- case 2:
- System.out.print("Ange radie: ");
- längd = input.nextDouble();
- bredd = input.nextDouble();
- höjd = input.nextDouble();
- volym = bredd * höjd * längd;
- break;
- case 3:
- System.out.print("Ange radie och höjd: ");
- radie = input.nextDouble();
- höjd = input.nextDouble();
- volym = PI * radie * radie * höjd;
- break;
- case 4:
- fortsätt = false;
- break;
- default:
- System.out.print("Felinmatning");
- break;
- }
- if(val == 1 || val == 2 || val == 3){
- System.out.print("Volym " + volym + "\n");
- }
- } while (fortsätt);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement