Advertisement
Dakufuren

Untitled

Sep 17th, 2014
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.31 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6.  
  7. package task3;
  8.  
  9. import java.util.Scanner;
  10.  
  11. /**
  12.  *
  13.  * @author AlbinSkola
  14.  */
  15. public class Task3 {
  16.  
  17.    
  18.     public static void main(String[] args) {
  19.         Task3 c = new Task3();
  20.         System.out.println("Volymen är :" + c.v() * c.VolumeGet() + "cm3");    
  21.         //System.out.println("Volym som behövs: " + c.v(0, 0, 0) * c.VolumeGet(0) + "cm3");
  22.     }
  23.    
  24.     int v () {
  25.         int l;
  26.         int b;
  27.         int h;
  28.        
  29.         Scanner scanner = new Scanner(System.in);
  30.        
  31.         System.out.println("Vad är längden?: ");
  32.         l = scanner.nextInt();
  33.        
  34.         System.out.println("Vad är bredden?: ");
  35.         b = scanner.nextInt();
  36.        
  37.         System.out.println("Vad är höjden?: ");
  38.         h = scanner.nextInt();
  39.    
  40.         int v = l * b * h;
  41.        
  42.         System.out.println("Volymen av en stack är: " + v + "cm3");
  43.        
  44.         return v;
  45.    
  46.     }
  47.    
  48.     int VolumeGet () {
  49.         int a;
  50.        
  51.         Scanner sc = new Scanner(System.in);
  52.         System.out.print("Ange antalet:");
  53.         a = sc.nextInt();
  54.         return a;
  55.    
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement