Advertisement
Dakufuren

Untitled

Sep 17th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.68 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 task3scanner;
  8.  
  9. import java.util.Scanner;
  10.  
  11. /**
  12.  *
  13.  * @author AlbinSkola
  14.  */
  15. public class Task3scanner {
  16.  
  17.     /**
  18.      * @param args the command line arguments
  19.      */
  20.     public static void main(String[] args) {
  21.         Task3scanner c = new Task3scanner();
  22.         int Volym;
  23.         //onödigt att definera l,b,h,a här kan inte få ut värdet från perimetrarna ändå
  24.         //eller går det? fråga läraren!
  25.        
  26.         int length = 0;
  27.         int width = 0;
  28.         int height = 0;
  29.        
  30.         int a = 0;
  31.         System.out.println("Volymen är :" + c.v(length, width, height) * c.VolumeGet(a) + "cm3");  
  32.         //System.out.println("Volym som behövs: " + c.v(0, 0, 0) * c.VolumeGet(0) + "cm3");
  33.     }
  34.    
  35.     int v (int length, int width, int height) {
  36.  
  37.        
  38.         Scanner scanner = new Scanner(System.in);
  39.        
  40.         System.out.println("Vad är längden?: ");
  41.         length = scanner.nextInt();
  42.        
  43.         System.out.println("Vad är bredden?: ");
  44.         width = scanner.nextInt();
  45.        
  46.         System.out.println("Vad är höjden?: ");
  47.         height = scanner.nextInt();
  48.    
  49.         int v = length * width * height;
  50.        
  51.         System.out.println("Volymen av en stack är: " + v + "cm3");
  52.        
  53.         return v;
  54.    
  55.     }
  56.    
  57.     int VolumeGet (int a) {
  58.  
  59.         Scanner sc = new Scanner(System.in);
  60.         System.out.print("Ange antalet:");
  61.         a = sc.nextInt();
  62.         return a;
  63.    
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement