ahmedsharaf2220's blog

By ahmedsharaf2220, history, 3 months ago, In English,

that`s task2

1 ~~~~~ package task2;

import java.util.Random; public class Task2 {

public static void main(String[] args) {
    Random num=new Random();
    int number;
    for (int i =1;i<=12;i++){
         number=1+num.nextInt(12);
         if (number==1)
             System .out.println (number+  "\t"+"januray");
         else if (number==2)
             System .out.println (number+  "\t"+"februry");
          else if (number==3)
             System .out.println (number+  "\t"+"march");

          else if (number==4)
             System .out.println (number + "\t"+"april");

          else if (number==5)
             System .out.println (number+  "\t"+"may");

          else if (number==6)
             System .out.println (number+  "\t"+"june");

          else if (number==7)
             System .out.println (number+  "\t"+"july");

          else if (number==8)
             System .out.println (number+  "\t"+"Augst");
     else if (number==9)
             System .out.println (number+  "\t"+"september");
          else if (number==10)
             System .out.println (number+  "\t"+"october");
          else if (number==11)
             System .out.println (number+  "\t"+"november");
          else if (number==12)
             System .out.println (number+  "\t"+"december");





    }
}

} ~~~~~

2 ~~~~~

package task2; import java.util.Scanner; public class Task2 {

public static void main(String[] args) {
int year;
int month;
Scanner x=new Scanner(System.in);
System.out.println("enter the month");
month=x.nextInt();
System.out.println("enter the year");
 year=x.nextInt();
 if (year%4==0&&month==2)
     System.out.println("Feburary of " +year+ "is 29");
 else if (year%4!=0&&month==2)
     System.out.println("Feburary of " +year+ "is 28");
 switch (month){
     case 1:
         System.out.println("january of "+year +"is 31");
         break;
         case 3:
         System.out.println("march of "+year +"is 31");
         break;
         case 4:
         System.out.println("april of "+year +"is 30");
         break;
         case 5:    
         System.out.println("may of "+year +"is 31");
         break;
         case 6:
         System.out.println("june of "+year +"is 30");
         break;
         case 7:
         System.out.println("july of "+year +"is 31");
         break;
         case 8:
         System.out.println("agust of "+year +"is 31");
         break;
         case 9:
         System.out.println("septemper of "+year +"is 30");
         break;
         case 10:
         System.out.println("october of "+year +"is 31");
         break;
         case 11:
         System.out.println("november of "+year +"is 30");
         break;
         case 12:
         System.out.println("december of "+year +"is 31");
         break;
         default: System.out.println("Enter right month");

 }



    }
}


3

package task2; import java.util.Scanner; public class Task2 {

public static void main(String[] args) {
int number;
System.out.println("Enter a number of three digit");
Scanner x=new Scanner(System.in);
int c=x.nextInt();
    int f=c%100;
    int l=c%10;

if (f==l)
System.out .println("this is plindromre"); else System.out .println("this isn't plindromre"); } } ~~~~~

5


package task2; import java.util.Scanner; public class Task2 { public static void main(String[] args) { int number; System.out.println("Enter a character "); Scanner x=new Scanner(System.in); String c=x.nextLine(); char ch=c.charAt(0); if (c.length()==1){ System.out.println("the unicode of \t"+ ch +"\t"+(int) ch); } } }

6 ~~~~~

package task2; import java.util.Scanner; import java.util.Random; public class Task2 {

public static void main(String[] args) {
   int number;
    System.out.println("you have to choose ( 0-sessiors \t" + " 1-stone\t" + "2-paper )");
    Random num=new Random ();
     number=num.nextInt(3);
     System .out.println(number);
     Scanner n=new Scanner(System.in);
     int hand=n.nextByte();
     //equals
     if (hand==0&&hand==number)
         System.out.println("equals");
     else if (hand==1&&hand==number)
          System.out.println("equals");
      else if (hand==2&&hand==number)
     System.out.println("equals");
      //0

     else if (hand==0&&number==1)
          System.out.println("computer wins ");
     else if (hand ==0&&number==2)
         System.out.println("you win ");
     else if (hand ==1&&number==0)
     System.out.println("computer wins ");
     else if (hand ==1&&number==2)
     System.out.println("you win ");
     else if (hand ==2&&number==0)
     System.out.println("computer wins ");
    else if (hand ==2&&number==1)
     System.out.println("you win ");

}

} ~~~~~

7


package task2; import java.util.Scanner; import java.util.Random; public class Task2 { public static void main(String[] args) { Random num=new Random (); int number; number=num.nextInt(2); System.out.println("Enter 1 or 0"); Scanner input=new Scanner(System.in); int coin =input.nextInt(); switch(coin){ case 0: if (coin==0&&coin==number) System.out.println("true"); else System.out.println("false"); break; case 1: if (coin==1&&coin==number) System.out.println("true"); else System.out.println("false"); break; default: System.out.println("just 1,0"); break; } } }
 
 
 
 
  • Vote: I like it  
  • -7
  • Vote: I do not like it