Goodiny777

Targilei tahbir 1.1-3.8

Feb 14th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.77 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class testerChoice {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.         //Targi 1.l
  7.        final double PI = Math.PI;
  8.         System.out.println("Enter the radius: ");
  9.         int radius =  scan.nextInt();
  10.         System.out.printf("Circle's preimeter: %f\n"+" Circles square: %f \n", radius*radius*PI, radius*2*PI);
  11.  
  12.         //Targil 1.2
  13.         final int TOAST_COST = 12, CHEAP_ADD = 2, EXP_ADD = 3;
  14.         int mySandwich = 0;
  15.         System.out.println("Do you want some sandwiches? 0 for nothing");
  16.         mySandwich += mySandwich += scan.nextInt() * TOAST_COST;
  17.         System.out.println("How much cheap additions do you want? 0 for nothing");
  18.         mySandwich += scan.nextInt() * CHEAP_ADD;
  19.         System.out.println("How much expensive additions do you want? 0 for nothing");
  20.         mySandwich += scan.nextInt() * EXP_ADD;
  21.         System.out.println("Your sandwich cost: "+ mySandwich);
  22.  
  23.         //Targil 1.3
  24.         final int KM_PRICE = 5, WORK_PRICE = 1;
  25.         final double TIPS = 1.1;
  26.         int price, weight, distance, floor;
  27.         System.out.println("Enter the price, the weight of furniture, distance to home, and the floor: ");
  28.         price = scan.nextInt();
  29.         weight = scan.nextInt();
  30.         distance = scan.nextInt();
  31.         floor = scan.nextInt();
  32.         System.out.printf("Total price: %d",(int)(price*TIPS+floor*weight*WORK_PRICE+distance*KM_PRICE));
  33.  
  34.        //Targil 2.1
  35.         System.out.println("Enter your age: ");
  36.         int age_2_1 = scan.nextInt();
  37.         System.out.printf("You are - %s", age_2_1<18?"Tzair":"Boger");
  38.  
  39.        //Targil 2.2
  40.         String res = "You are: ";
  41.         System.out.println("Enter your age: ");
  42.         int age_2_2 = scan.nextInt();
  43.         if(age_2_2<18){
  44.             res+="Tzair";
  45.         }else if(age_2_2<65){
  46.             res+="Boger";
  47.         }else{
  48.             res+="Pensioner";
  49.         }
  50.         System.out.println(res);
  51.  
  52.         //Targil 2.3
  53.         System.out.println("Enter a three-digit number: ");
  54.         int num = scan.nextInt();
  55.         if(num%10==num/10){
  56.             System.out.println("It's good");
  57.         }
  58.  
  59.         //Targil2.4
  60.         System.out.println("Enter a three-digit number: ");
  61.         int num_2_4 = scan.nextInt();
  62.         if(((num_2_4%100)/10==num_2_4%10)&&(num_2_4/100==num_2_4%10)) {
  63.             System.out.println("It's good");
  64.         }
  65.  
  66.         //Targil 2.5
  67.         System.out.println("Enter a two-digit number: ");
  68.         int num_2_5 = scan.nextInt();
  69.         if(num_2_5/10!=9){ //מספר שמאלי לא 9 אחרת אין מה לבדוק
  70.             if((num_2_5/10)+1==num_2_5%10){
  71.                 System.out.println("It's good");
  72.             }
  73.         }
  74.  
  75.         //Targil 2.6
  76.         System.out.println("Enter a three-digit number: ");
  77.         int num_2_6 = scan.nextInt();
  78.         //מספרים שמאלי ואמצעי הם לא 9 אחרת אין מה לבדוק
  79.         if((num_2_6/100!=9)&&(num_2_6/10%10!=9)) {
  80.             //אם המספר הכי שמאלי פחות ב1 ממספר באמצע וגם מספר בעמצע פחות ב1 ממספר הכי ימיני
  81.             if ((num_2_6 / 100 + 1 == (num_2_6 / 10 % 10)) && (num_2_6 /10 % 10 + 1 == num_2_6 % 10)) {
  82.                 System.out.println("It's good");
  83.             }
  84.         }
  85.  
  86.         //Targil 2.7
  87.         System.out.println("Enter tank capacity and how much gas in the tank: ");
  88.         System.out.printf("%s", (scan.nextInt() * 0.15<scan.nextInt()) ? "You don't need gas" : "You need more gas");
  89.  
  90.         //Targil 2.8
  91.         System.out.println("Enter a time for finish runing: ");
  92.         int f_time = scan.nextInt();
  93.         String res_2_8 = "You are in the group: ";
  94.         if(f_time<=50){
  95.             res_2_8+="A";
  96.         }else if(f_time<=60){
  97.             res_2_8+="B";
  98.         }else{
  99.             res_2_8+="C";
  100.         }
  101.         System.out.println(res_2_8);
  102.  
  103.         //Targil 2.9
  104.         System.out.println("Enter date: ");
  105.         int date_2_9 = scan.nextInt();
  106.         int year = date_2_9%10000;
  107.         int month = (date_2_9/10000)%100;
  108.         int day = date_2_9/1000000;
  109.         System.out.printf("The year if %d, the month is %d, the day %d", year, month, day);
  110.  
  111.         //Targil 2.10
  112.         System.out.println("Enter date: ");
  113.         int date_2_10 = scan.nextInt();
  114.         int month_2_10 = (date_2_10/10000)%100;
  115.         String res_2_10 = "The season of your date is: ";
  116.         if ((month_2_10==12)||(month_2_10==1)||(month_2_10==2)){
  117.             res_2_10+="winter";
  118.         }else if ((month_2_10==3)||(month_2_10==4)||(month_2_10==5)){
  119.             res_2_10+="spring";
  120.         }else if ((month_2_10==6)||(month_2_10==7)||(month_2_10==8)){
  121.             res_2_10+="summer";
  122.         }else {
  123.             res_2_10 += "autumn";
  124.         }
  125.         System.out.printf(res_2_10);
  126.  
  127.         //Targil 3.1
  128.         for(int i=0;i<5;){
  129.             if(scan.nextInt()%2==0){
  130.                 i+=1;
  131.             }
  132.         }
  133.  
  134.         //Targil 3.2
  135.         int counter_3_2=0;
  136.         for(int i=0;i<10; i+=1){
  137.             if(scan.nextInt()%2==0){
  138.                 counter_3_2+=1;
  139.             }
  140.         }
  141.         System.out.println("Amount of event numbers: "+counter_3_2);
  142.  
  143.         //Targil 3.3
  144.         int count_3_3;
  145.         for(count_3_3=0;count_3_3<5;){
  146.             System.out.println("Enter letter: ");
  147.             char ot = scan.next().charAt(0);
  148.             if((ot>='A')&&(ot<='Z')){
  149.                 count_3_3+=1;
  150.             }
  151.         }
  152.         System.out.printf("You entered %d letters",count_3_3);
  153.  
  154.         //Targil 3.4
  155.         int counter_3_4=0;
  156.         for(int i=0; i<10; i+=1){
  157.             System.out.println("Enter letter: ");
  158.             char ot_3_4 = scan.next().charAt(0);
  159.             if((ot_3_4>='a')&&(ot_3_4<='a')){
  160.                 counter_3_4 += 1;
  161.             }
  162.         }
  163.         System.out.printf("You entered %d lowercase letters",counter_3_4);
  164.  
  165.         //Targil 3.5
  166.         int num_3_5;
  167.         do{
  168.             System.out.println("Enter two-digit number: ");
  169.             num_3_5 = scan.nextInt();
  170.         }while(num_3_5%11!=0);
  171.  
  172.         //Targil 3.6
  173.         int num_3_6;
  174.         do{
  175.             System.out.println("Enter three-digit number: ");
  176.             num_3_6 = scan.nextInt();
  177.         }while(num_3_6/100>0);
  178.  
  179.         //Targil 3.7
  180.         int num_3_7;
  181.         do{
  182.             System.out.println("Enter three-digit number: ");
  183.             num_3_7 = scan.nextInt();
  184.         }while(num_3_7%7!=0);
  185.  
  186.         //Targil 3.8
  187.         int num_3_8 = scan.nextInt();
  188.         for(int i=1; i<=num_3_8; i+=1){
  189.             if(i%7==0){
  190.                 System.out.println("Boom");
  191.             }else{
  192.                 System.out.print(i+" ");
  193.             }
  194.         }
Advertisement
Add Comment
Please, Sign In to add comment