Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class testerChoice {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- //Targi 1.l
- final double PI = Math.PI;
- System.out.println("Enter the radius: ");
- int radius = scan.nextInt();
- System.out.printf("Circle's preimeter: %f\n"+" Circles square: %f \n", radius*radius*PI, radius*2*PI);
- //Targil 1.2
- final int TOAST_COST = 12, CHEAP_ADD = 2, EXP_ADD = 3;
- int mySandwich = 0;
- System.out.println("Do you want some sandwiches? 0 for nothing");
- mySandwich += mySandwich += scan.nextInt() * TOAST_COST;
- System.out.println("How much cheap additions do you want? 0 for nothing");
- mySandwich += scan.nextInt() * CHEAP_ADD;
- System.out.println("How much expensive additions do you want? 0 for nothing");
- mySandwich += scan.nextInt() * EXP_ADD;
- System.out.println("Your sandwich cost: "+ mySandwich);
- //Targil 1.3
- final int KM_PRICE = 5, WORK_PRICE = 1;
- final double TIPS = 1.1;
- int price, weight, distance, floor;
- System.out.println("Enter the price, the weight of furniture, distance to home, and the floor: ");
- price = scan.nextInt();
- weight = scan.nextInt();
- distance = scan.nextInt();
- floor = scan.nextInt();
- System.out.printf("Total price: %d",(int)(price*TIPS+floor*weight*WORK_PRICE+distance*KM_PRICE));
- //Targil 2.1
- System.out.println("Enter your age: ");
- int age_2_1 = scan.nextInt();
- System.out.printf("You are - %s", age_2_1<18?"Tzair":"Boger");
- //Targil 2.2
- String res = "You are: ";
- System.out.println("Enter your age: ");
- int age_2_2 = scan.nextInt();
- if(age_2_2<18){
- res+="Tzair";
- }else if(age_2_2<65){
- res+="Boger";
- }else{
- res+="Pensioner";
- }
- System.out.println(res);
- //Targil 2.3
- System.out.println("Enter a three-digit number: ");
- int num = scan.nextInt();
- if(num%10==num/10){
- System.out.println("It's good");
- }
- //Targil2.4
- System.out.println("Enter a three-digit number: ");
- int num_2_4 = scan.nextInt();
- if(((num_2_4%100)/10==num_2_4%10)&&(num_2_4/100==num_2_4%10)) {
- System.out.println("It's good");
- }
- //Targil 2.5
- System.out.println("Enter a two-digit number: ");
- int num_2_5 = scan.nextInt();
- if(num_2_5/10!=9){ //מספר שמאלי לא 9 אחרת אין מה לבדוק
- if((num_2_5/10)+1==num_2_5%10){
- System.out.println("It's good");
- }
- }
- //Targil 2.6
- System.out.println("Enter a three-digit number: ");
- int num_2_6 = scan.nextInt();
- //מספרים שמאלי ואמצעי הם לא 9 אחרת אין מה לבדוק
- if((num_2_6/100!=9)&&(num_2_6/10%10!=9)) {
- //אם המספר הכי שמאלי פחות ב1 ממספר באמצע וגם מספר בעמצע פחות ב1 ממספר הכי ימיני
- if ((num_2_6 / 100 + 1 == (num_2_6 / 10 % 10)) && (num_2_6 /10 % 10 + 1 == num_2_6 % 10)) {
- System.out.println("It's good");
- }
- }
- //Targil 2.7
- System.out.println("Enter tank capacity and how much gas in the tank: ");
- System.out.printf("%s", (scan.nextInt() * 0.15<scan.nextInt()) ? "You don't need gas" : "You need more gas");
- //Targil 2.8
- System.out.println("Enter a time for finish runing: ");
- int f_time = scan.nextInt();
- String res_2_8 = "You are in the group: ";
- if(f_time<=50){
- res_2_8+="A";
- }else if(f_time<=60){
- res_2_8+="B";
- }else{
- res_2_8+="C";
- }
- System.out.println(res_2_8);
- //Targil 2.9
- System.out.println("Enter date: ");
- int date_2_9 = scan.nextInt();
- int year = date_2_9%10000;
- int month = (date_2_9/10000)%100;
- int day = date_2_9/1000000;
- System.out.printf("The year if %d, the month is %d, the day %d", year, month, day);
- //Targil 2.10
- System.out.println("Enter date: ");
- int date_2_10 = scan.nextInt();
- int month_2_10 = (date_2_10/10000)%100;
- String res_2_10 = "The season of your date is: ";
- if ((month_2_10==12)||(month_2_10==1)||(month_2_10==2)){
- res_2_10+="winter";
- }else if ((month_2_10==3)||(month_2_10==4)||(month_2_10==5)){
- res_2_10+="spring";
- }else if ((month_2_10==6)||(month_2_10==7)||(month_2_10==8)){
- res_2_10+="summer";
- }else {
- res_2_10 += "autumn";
- }
- System.out.printf(res_2_10);
- //Targil 3.1
- for(int i=0;i<5;){
- if(scan.nextInt()%2==0){
- i+=1;
- }
- }
- //Targil 3.2
- int counter_3_2=0;
- for(int i=0;i<10; i+=1){
- if(scan.nextInt()%2==0){
- counter_3_2+=1;
- }
- }
- System.out.println("Amount of event numbers: "+counter_3_2);
- //Targil 3.3
- int count_3_3;
- for(count_3_3=0;count_3_3<5;){
- System.out.println("Enter letter: ");
- char ot = scan.next().charAt(0);
- if((ot>='A')&&(ot<='Z')){
- count_3_3+=1;
- }
- }
- System.out.printf("You entered %d letters",count_3_3);
- //Targil 3.4
- int counter_3_4=0;
- for(int i=0; i<10; i+=1){
- System.out.println("Enter letter: ");
- char ot_3_4 = scan.next().charAt(0);
- if((ot_3_4>='a')&&(ot_3_4<='a')){
- counter_3_4 += 1;
- }
- }
- System.out.printf("You entered %d lowercase letters",counter_3_4);
- //Targil 3.5
- int num_3_5;
- do{
- System.out.println("Enter two-digit number: ");
- num_3_5 = scan.nextInt();
- }while(num_3_5%11!=0);
- //Targil 3.6
- int num_3_6;
- do{
- System.out.println("Enter three-digit number: ");
- num_3_6 = scan.nextInt();
- }while(num_3_6/100>0);
- //Targil 3.7
- int num_3_7;
- do{
- System.out.println("Enter three-digit number: ");
- num_3_7 = scan.nextInt();
- }while(num_3_7%7!=0);
- //Targil 3.8
- int num_3_8 = scan.nextInt();
- for(int i=1; i<=num_3_8; i+=1){
- if(i%7==0){
- System.out.println("Boom");
- }else{
- System.out.print(i+" ");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment