Advertisement
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 scanDl = new Scanner(System.in);
- System.out.println("Wpisz długość:");
- int dlugosc = scanDl.nextInt();
- Scanner scanSz = new Scanner(System.in);
- System.out.println("Wpisz szerokośc:");
- int szerokosc = scanDl.nextInt();
- int[][] blacha = new int[dlugosc][szerokosc];
- for (int i = 0; i < blacha.length; i++) {
- for (int j = 0; j < blacha[i].length; j++) {
- System.out.print(blacha[i][j]);
- }
- System.out.println();
- }
- int x = szerokosc - 1;
- int y = dlugosc - 1;
- int iloscCiecX = x *(y+1);
- int[] kosztCiecX = new int[x];
- for(int i = 0; i < kosztCiecX.length; i++){
- Scanner scanKosztX = new Scanner(System.in);
- System.out.println("Wpisz X"+(i+1));
- kosztCiecX[i] = scanKosztX.nextInt();
- }
- System.out.println("Ilość cięć na szerokość (X):" + iloscCiecX);
- int iloscCiecY = y;
- int[] kosztCiecY = new int[y];
- for(int i = 0; i < kosztCiecY.length; i++){
- Scanner scanKosztY = new Scanner(System.in);
- System.out.println("Wpisz Y"+(i+1));
- kosztCiecY[i] = scanKosztY.nextInt();
- }
- System.out.println("Ilość cięć na dlugosc (Y):" +iloscCiecY);
- int iloscCiec = (y + ((y+1)*x));
- System.out.println("Ilosc wszystkich ciec: " + iloscCiec);
- int sumaX = 0;
- for (int i=0; i<kosztCiecX.length ; i++) {
- sumaX += kosztCiecX[i];
- }
- System.out.println("x: "+sumaX);
- int sumaY = 0;
- for (int i=0; i<kosztCiecY.length ; i++) {
- sumaY += kosztCiecY[i];
- }
- System.out.println("y: "+sumaY);
- int calyKoszt1 = sumaX + (szerokosc*sumaY);
- System.out.println("koszt1: "+calyKoszt1);
- int calyKoszt2 = sumaY + (dlugosc*sumaX);
- System.out.println("Koszt2: "+calyKoszt2);
- if(calyKoszt1<calyKoszt2){
- System.out.println("Najnizszy koszt wynosi: " + calyKoszt1);
- }else{
- System.out.println("Najnizszy koszt wynosi: " + calyKoszt2);
- }
- // Scanner scanKosztX = new Scanner(System.in);
- // System.out.println("Wpisz koszt cięć X("+iloscCiecX+"):");
- // int kosztX = scanKosztX.nextInt();
- // Scanner scanKosztY = new Scanner(System.in);
- // System.out.println("Wpisz Koszt ciec Y("+iloscCiecY+"):");
- // int kosztY = scanKosztY.nextInt();
- //int koszt = (iloscCiecX * kosztX)+(iloscCiecY*kosztY);
- // System.out.println("Koszt pociecia wyniesie: "+koszt);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement