Advertisement
Guest User

maor homework2

a guest
Nov 18th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 19.38 KB | None | 0 0
  1. //////////////////////////////////////////////////////////////////////////////////////////////////////////
  2.                                     PEREK 1
  3. \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  4. TARGIL 1
  5. package com.company;
  6.  
  7. import java.util.Scanner;
  8.  
  9. public class Main {
  10.  
  11.     public static void main(String[] args) {
  12.         Scanner s = new Scanner(System.in);
  13.         double radios;
  14.         System.out.println("give me a radios");
  15.         radios=s.nextDouble();
  16.         System.out.println("circumference of the circle:"+(2*radios*3.14));
  17.         System.out.println("space of circle:"+(3.1415*radios)*(3.1415*radios));
  18.     }
  19.  
  20. }
  21. ////////////////////////////////////////////////////////////////////////////////////////
  22. TARGIL 2
  23.  
  24. package com.company;
  25.  
  26. import java.util.Scanner;
  27.  
  28. public class Main
  29. {
  30.  
  31.     public static void main(String[] args)
  32.     {
  33.     Scanner s = new Scanner(System.in);
  34.         System.out.println();
  35.         final int TOST=12,EX1=2,EX2=3;
  36.         int num1,num2;
  37.         System.out.println("how much cheap extra you want?/corn/olives");
  38.         num1=s.nextInt()*EX1;
  39.         System.out.println("how mum exepensive extras you want?/cheese/mushrooms");
  40.         num2=s.nextInt()*EX2;
  41.         System.out.println("you need to pay:"+(TOST+num1+num2));
  42.  
  43.  
  44.  
  45.  
  46.         }
  47.     }
  48. ////////////////////////////////////////////////////////////////////////////////////////////
  49.  TARGIL 3
  50. package com.company;
  51.  
  52. import java.util.Scanner;
  53.  
  54. public class Main
  55. {
  56.  
  57.     public static void main(String[] args)
  58.     {
  59.  
  60.         Scanner s =new Scanner(System.in);
  61.         final int DELIVERY=5,FLOOR=1;
  62.         final double TIP=0.1;
  63.         int kg,km,price,floor,cost;
  64.         System.out.println("what price of the product?");
  65.         price=s.nextInt();
  66.         System.out.println("how much km of delivery? which floor? and how many kg's?");
  67.         km=s.nextInt();
  68.         floor=s.nextInt();
  69.         kg=s.nextInt();
  70.  
  71.         cost= (int) (price*TIP+FLOOR*kg*floor+km*DELIVERY+price);
  72.         System.out.println(cost);
  73.  
  74.  
  75.     }
  76.  
  77.     }
  78. \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  79.                                         PEREK 2
  80. ////////////////////////////////////////////////////////////////////////////////////////////
  81. TARGIL 1
  82. package com.company;
  83.  
  84. import java.util.Scanner;
  85.  
  86. public class Main {
  87.  
  88.     public static void main(String[] args) {
  89.         Scanner s= new Scanner(System.in);
  90.         final int age=18;
  91.         int num;
  92.         System.out.println("what is your age");
  93.         num=s.nextInt();
  94.         System.out.println(num>18?"your old":"your a child");
  95.         }
  96. }
  97.  
  98.  
  99.  
  100. ///////////////////////////////////////////////////////////////////////////////////////////////////
  101. PEREK 2 TARGIL 2
  102. package com.company;
  103.  
  104. import java.util.Scanner;
  105.  
  106. public class Main {
  107.  
  108.     public static void main(String[] args) {
  109.         Scanner s= new Scanner(System.in);
  110.         final int age=18;
  111.         int num;
  112.         System.out.println("what is your age");
  113.         num=s.nextInt();
  114.         if (num>age&&num<65)
  115.         {
  116.             System.out.println("your a man");
  117.         }
  118.         if (num>=65)
  119.         {
  120.             System.out.println("pansioner");
  121.         }
  122.             if(num<18) {
  123.                 System.out.println("your a child");
  124.             }
  125.  
  126.     }
  127. }
  128. ///////////////////////////////////////////////////////////////////////////////////////
  129. TARGIL 3
  130. package com.company;
  131.  
  132. import java.util.Scanner;
  133.  
  134. public class Main {
  135.  
  136.     public static void main(String[] args) {
  137.  
  138.         Scanner s = new Scanner(System.in);
  139.         int num;
  140.         System.out.println("please give me a num bigger than 10");
  141.         num = s.nextInt();
  142.         System.out.println(num % 10 == num /10 ? "the same num's" : "not the same");
  143.     }
  144.  
  145. }
  146. ///////////////////////////////////////////////////////////////////////////////////////////////
  147. TARGIL 4
  148.  
  149. import java.util.Scanner;
  150.  
  151. public class Main {
  152.  
  153.     public static void main(String[] args) {
  154.  
  155.         Scanner s = new Scanner(System.in);
  156.         int num,temp,num1,num2,num3;
  157.         boolean isSame=false;
  158.         System.out.println("please give me a num bigger than 99");
  159.         num = s.nextInt();
  160.         temp=num;    
  161.         num1=temp%10;  
  162.         temp/=10;      
  163.         num2=temp%10;  
  164.         num3=temp/10;
  165.         isSame=num1==num2 && num2==num3;
  166.         System.out.println("the number is "+(isSame?"":"NOT")+" same");
  167.  
  168.  
  169. }}
  170. ////////////////////////////////////////////////////////////////////////////////////////////////////
  171. TARGIL 5
  172. package com.company;
  173.  
  174. import java.util.Scanner;
  175.  
  176. public class Main {
  177.  
  178.     public static void main(String[] args) {
  179.  
  180.         Scanner s = new Scanner(System.in);
  181.         int num;
  182.         System.out.println("please give me a num bigger than 99");
  183.         num = s.nextInt(); //45
  184.         System.out.println(num%10==(num/10+1)?"follow num's":"not follow");// 4+1=5
  185.  
  186.  
  187. }}
  188.  
  189.  
  190. //////////////////////////////////////////////////////////////////////////////////////////////////////
  191. TARGIL 6
  192. package com.company;
  193.  
  194. import java.util.Scanner;
  195.  
  196. public class Main
  197. {
  198.  
  199.     public static void main(String[] args)
  200.     {
  201.         Scanner s = new Scanner(System.in);
  202.         int num,temp,num1,num2,num3;
  203.         boolean isfollow;
  204.         System.out.println("please give me a num bigger than 99");
  205.         num = s.nextInt();
  206.         temp=num;
  207.         num1=temp/100;
  208.         num2=(temp/10)%10;
  209.         num3=temp%10;
  210.         isfollow=num1+2==num2+1&&(num2+1)==num3;
  211.         System.out.println("the num's is:"+(isfollow?"":"NOT")+" "+"FOLLOW");
  212.  
  213.  
  214.  
  215.     }
  216. }
  217. ///////////////////////////////////////////////////////////////////////////////////////////////////////////
  218. TARGIL 7
  219. package com.company;
  220.  
  221. import java.util.Scanner;
  222.  
  223. public class Main
  224. {
  225.  
  226.     public static void main(String[] args)
  227.     {
  228.         Scanner s = new Scanner(System.in);
  229.         final double FUEL=0.15;
  230.         double full,gas;
  231.         System.out.println("how much you have in the tank?");
  232.         full=s.nextDouble();
  233.         System.out.println("how much litters gas did you really have?");
  234.         gas=s.nextDouble();
  235.  
  236.         System.out.println(FUEL*full<gas?"you can drive":"go to gas station!");
  237.  
  238.     }
  239. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  240. TARGIL 8
  241. public class Main {
  242.  
  243.     public static void main(String[] args)
  244.     {
  245.         Scanner s=new Scanner(System.in);
  246.         int runnerA;
  247.         System.out.println("how many minutes do you think you'll finish the race?");
  248.         runnerA=s.nextInt();
  249.         if (runnerA<=50)
  250.         {
  251.             System.out.println("run in A run");
  252.         }
  253.         if (runnerA>=50&&runnerA<=60)
  254.         {
  255.             System.out.println("run in B run");
  256.         }
  257.         if (runnerA>60)
  258.          {
  259.         System.out.println("run in C run fat mann!!");
  260.          }
  261.     }
  262. }
  263. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  264. TARGIL 9
  265. package com.company;
  266.  
  267. import java.util.Scanner;
  268.  
  269. public class Main {
  270.  
  271.     public static void main(String[] args)
  272.     {
  273.         Scanner s = new Scanner(System.in);
  274.        int num,num1,num2,num3,temp;
  275.         System.out.println("please enter your date");
  276.         num=s.nextInt();
  277.         temp=num;
  278.         num1=temp%10000;
  279.         temp/=10000;
  280.         num2=temp%100;
  281.         temp/=100;
  282.         num3=temp%100;
  283.         temp/=10;
  284.         System.out.println("the year"+num1+"your month:"+num2+"your day:"+num3);
  285.  
  286.  
  287.     }
  288. }
  289. /////////////////////////////////////////////////////////////////////////////////////////////////////
  290. TARGIL 10
  291. package com.company;
  292.  
  293. import java.util.Scanner;
  294.  
  295. public class Main {
  296.  
  297.     public static void main(String[] args)
  298.     {
  299.         Scanner s = new Scanner(System.in);
  300.         int num,num1,num2,num3,temp;
  301.         System.out.println("please enter date");
  302.         num=s.nextInt();
  303.         temp=num;
  304.         num1=temp%10000;
  305.         temp/=10000;
  306.         num2=temp%100;
  307.         temp/=100;
  308.         num3=temp%100;
  309.         temp/=10;
  310.         if (num2>=3&&num2<=5)
  311.         {
  312.             System.out.println("your season is aviv");
  313.         }
  314.         if (num2>=6&&num2<=8)
  315.         {
  316.             System.out.println("your season is summer");
  317.         }
  318.         if (num2>=9&&num2<=11)
  319.         {
  320.             System.out.println("your season is stav");
  321.         }
  322.         if (num2>=12&&num2<=2)
  323.         {
  324.             System.out.println("your season is horef");
  325.         }
  326.     }
  327. }
  328. ///////////////////////////////////////////////////////////////////////////////////////////////////////////
  329.                                                 PEREK 3
  330. \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  331. TARGIL 1
  332.  
  333. package com.company;
  334.  
  335. import java.util.Scanner;
  336.  
  337. public class Main
  338. {
  339.  
  340.     public static void main(String[] args)
  341.     {
  342.         Scanner s = new Scanner(System.in);
  343.         int num = 0, counter = 0;
  344.  
  345.         while (counter < 5)
  346.         {
  347.             System.out.println("please enter num's");
  348.             num = s.nextInt();
  349.             if (num % 2 == 0)
  350.             {
  351.                 counter++;
  352.             }
  353.         }
  354.  
  355.         System.out.println("its ok!!! five num's even");
  356.     }
  357.  
  358. }
  359. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  360. TARGIL 2
  361. package com.company;
  362.  
  363. import java.util.Scanner;
  364.  
  365. public class Main {
  366.  
  367.  
  368.     public static void main(String[] args)
  369.         {
  370.                 Scanner s = new Scanner(System.in);
  371.                 int num = 0, counter = 0;
  372.             System.out.println("please enter ten num's");
  373.             for (int i=0;i<10;i++)
  374.             {
  375.                 num=s.nextInt();
  376.                 if (num%2!=0)
  377.                 {
  378.                     counter++;
  379.                 }
  380.  
  381.             }
  382.             System.out.println("you put:"+counter+" odd num's");
  383.         }
  384.  
  385.  
  386.     }
  387. //////////////////////////////////////////////////////////////////////////////////////////////////////////////
  388. TARGIL 3
  389. public class Main {
  390.  
  391.     public static void main(String[] args)
  392.     {
  393.         Scanner s = new Scanner(System.in);
  394.         char letters;
  395.         int counter=0;
  396.         System.out.println("put some char's");
  397.         for (int i=0;i<10;i++)
  398.         {
  399.             letters=s.next().charAt(0);
  400.             if (letters>='A'&&letters<='Z')
  401.             {
  402.                 counter++;
  403.             }
  404.  
  405.         }
  406.             System.out.println("you put:"+counter+" big letters");
  407.     }
  408.  
  409. }
  410. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  411. TARGIL 4
  412. package com.company;
  413.  
  414. import java.util.Scanner;
  415.  
  416. public class Main {
  417.  
  418.     public static void main(String[] args)
  419.     {
  420.         Scanner s = new Scanner(System.in);
  421.         char letters;
  422.         int counter=0;
  423.         System.out.println("put some char's");
  424.         for (int i=0;i<10;i++)
  425.         {
  426.             letters=s.next().charAt(0);
  427.             if (letters>='a'&&letters<='z')
  428.             {
  429.                 counter++;
  430.             }
  431.  
  432.         }
  433.             System.out.println("you put:"+counter+" small letters");
  434.     }
  435.  
  436. }
  437. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  438. TARGIL 5
  439. package com.company;
  440.  
  441. import java.util.Scanner;
  442.  
  443. public class Main
  444. {
  445.  
  446.     public static void main(String[] args)
  447.     {
  448.      Scanner s = new Scanner(System.in);
  449.      int num,counter=0;
  450.      System.out.println("put some num's");
  451.         while (counter<1)
  452.            {
  453.             num = s.nextInt();
  454.             if (num % 10 == num / 10)
  455.                 {
  456.                     counter++;
  457.                 }
  458.             }
  459.  
  460.         System.out.println("you put the same nums");
  461.     }
  462.  
  463. }
  464.  
  465.  
  466. ///////////////////////////////////////////////////////////////////////////////////////////////////////////
  467. TARGIL 6
  468. package com.company;
  469.  
  470. import java.util.Scanner;
  471.  
  472. public class Main
  473. {
  474.  
  475.     public static void main(String[] args)
  476.     {
  477.      Scanner s = new Scanner(System.in);
  478.      int num,counter=0;
  479.      System.out.println("put some num's");
  480.         while (counter<1)
  481.            {
  482.             num = s.nextInt();
  483.             if (num % 10 == num / 10)
  484.                 {
  485.                     counter++;
  486.                 }
  487.             }
  488.  
  489.         System.out.println("you put the same nums");
  490.     }
  491.  
  492. }
  493.  
  494. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  495. TARGIL 7
  496. package com.company;
  497.  
  498. import java.util.Scanner;
  499.  
  500. public class Main
  501. {
  502.  
  503.     public static void main(String[] args)
  504.     {
  505.         Scanner s = new Scanner(System.in);
  506.         int num,counter=0;
  507.         System.out.println("put some num's");
  508.         while (counter<1)
  509.         {
  510.             num = s.nextInt();
  511.             if (num % 7 == 0&&num>99&&num<999)
  512.             {
  513.                 counter++;
  514.             }
  515.         }
  516.  
  517.         System.out.println("7 BOOM SHAKA LUCK");
  518. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  519. TARGIL 8
  520. package com.company;
  521.  
  522. import java.util.Scanner;
  523.  
  524. public class Main
  525. {
  526.  
  527.     public static void main(String[] args)
  528.     {
  529.         Scanner s = new Scanner(System.in);
  530.         int num, counter = 0;
  531.         System.out.println("put a num");
  532.         num = s.nextInt();
  533.          for (int i=1;i<=num;i+=1)
  534.         {
  535.             System.out.print(i%7==0?" BOOM ":i+" ");
  536.  
  537.         }
  538.     }
  539. }
  540. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  541.                                             PEREK 2 C
  542. \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  543. TARGIL 1
  544. public class Main {
  545.  
  546.     public static void main(String[] args)
  547.     {
  548.         Scanner s= new Scanner(System.in);
  549.         int[]arr=new int[10];
  550.         boolean eveNums=false;
  551.         System.out.println("enter ten num's");
  552.         for (int i=0;i<arr.length;i++)
  553.         {
  554.             arr[i]=s.nextInt();
  555.  
  556.         }
  557.         for (int i=0;i<arr.length;i+=1)
  558.         {
  559.             eveNums=arr[i]%2==0;
  560.             if (eveNums)
  561.             {
  562.                 System.out.println(arr[i]);
  563.             }
  564.         }
  565.         }
  566. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  567. TARGIL 2
  568. public class Main {
  569.  
  570.     public static void main(String[] args) {
  571.         Scanner s = new Scanner(System.in);
  572.         boolean bigLetters=false;
  573.         char[] letters = new char[10];
  574.         System.out.println("put some char's");
  575.         for (int i =0;i<letters.length;i++)
  576.         {
  577.             letters[i]=s.next().charAt(0);
  578.         }
  579.         for (int i = 0;i<letters.length;i+=1)
  580.         {
  581.             bigLetters=letters[i] >= 'A' && letters[i] <= 'Z';
  582.             if (bigLetters){
  583.                 System.out.println("THE BIG LETTER IS:"+letters[i]);
  584.             }
  585.         }
  586.     }
  587. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  588. TARGIL 3
  589. public class Main {
  590.  
  591.     public static void main(String[] args)
  592.     {
  593.         Scanner s= new Scanner(System.in);
  594.         int[]arr=new int[10];
  595.         System.out.println("enter ten num's");
  596.         for (int i=0;i<arr.length;i++)
  597.         {
  598.             arr[i] = s.nextInt();
  599.         }
  600.             for (int i=0;i<arr.length;i++)
  601.                 if (arr[i] % 3 == 0) {
  602.                     System.out.println(arr[i]);
  603.  
  604.             }
  605.  
  606.         }
  607.  
  608.     }
  609. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  610. TARGIL 4
  611. public class Main {
  612.  
  613.     public static void main(String[] args)
  614.     {
  615.         Scanner s= new Scanner(System.in);
  616.         int[]arr=new int[10];
  617.         System.out.println("enter ten num's");
  618.         for (int i=0;i<arr.length;i++)
  619.         {
  620.             arr[i] = s.nextInt();
  621.         }
  622.             for (int i=0;i<arr.length;i++)
  623.                 if (arr[i]%2 == 0) {
  624.                     arr[i]+=1;
  625.                     System.out.println(arr[i]);
  626. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  627. TARGIL 5
  628. public class Main {
  629.  
  630.     public static void main(String[] args) {
  631.         Scanner s = new Scanner(System.in);
  632.         int[] arr = new int[10];
  633.         System.out.println("enter ten num's");
  634.         for (int i = 0; i < arr.length; i++) {
  635.             arr[i] = s.nextInt();
  636.         }
  637.         for (int i = 0; i < arr.length; i++) {
  638.             if (i % 2 == 0) {
  639.                 System.out.println(arr[i] + 1);
  640.             }
  641.                 if (i!=0&&i% 3 == 0) {
  642.                     System.out.println(arr[i]-1);
  643.                 }
  644.             }
  645. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  646. TARGIL 6
  647. public class Main {
  648.  
  649.     public static void main(String[] args)
  650.  
  651.     {
  652.         Scanner s = new Scanner(System.in);
  653.         int counter=0;
  654.         char[]letters=new char[10];
  655.         char ch;
  656.         System.out.println("put any char");
  657.         ch=s.next().charAt(0);
  658.         for (int i =0;i<10;i+=1)
  659.         {
  660.             System.out.println("enter some char's");
  661.             letters[i] = s.next().charAt(0);
  662.         }
  663.  
  664.         for (int i=0;i<10;i++)
  665.         {
  666.             if(letters[i]==ch)
  667.                 counter+=1;
  668.  
  669.         }
  670.         System.out.println(" you put the:"+ch+" "+counter+"  times");
  671.     }
  672. }
  673. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  674. TARGIL 7
  675. public class Main
  676. {
  677.  
  678.     public static void main(String[] args) {
  679.         Scanner s = new Scanner(System.in);
  680.         int[][]arr=new int[5][5];
  681.         System.out.println("enter few num's");
  682.         for (int i=0;i<arr.length;i++)
  683.         {
  684.             arr[0][i]=s.nextInt();
  685.         }
  686.         System.out.println("enter few num's");
  687.         for (int i=0;i<arr.length;i++)
  688.         {
  689.             arr[1][i]=s.nextInt();
  690.         }
  691.         for (int i=0;i<arr.length;i++)
  692.         {
  693.             if (arr[0][i]==arr[1][i])
  694.             {
  695.                 System.out.println("you put the same num in the: "+i+ " cave");
  696.             }
  697.         }
  698. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  699. TARGIL 8
  700. public class Main {
  701.  
  702.     public static void main(String[] args) {
  703.         Scanner s = new Scanner(System.in);
  704.         int[][][] arr = new int[5][5][5];
  705.         System.out.println("put 10 num's");
  706.         for (int i=0;i<arr.length;i+=1)
  707.         {
  708.             arr[0][i][i]=s.nextInt();
  709.         }
  710.         for (int i=0;i<arr.length;i+=1)
  711.         {
  712.             arr[1][i][i]=s.nextInt();
  713.         }
  714.         for (int i=0;i<5;i+=1)
  715.         {
  716.             arr[2][i][i]=arr[1][i][i]+arr[0][i][i];
  717.             System.out.println(arr[2][i][i]);
  718.         }
  719.  
  720.  
  721.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement