Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- שאלה 1
- public class aboveX\4 {
- public aboveX() {
- // TODO Auto-generated constructor stub
- }
- /**
- * @to count the numbers which are bigger then x in an array
- */
- public static void main(String[] args) {
- int x=56;
- int[]arrays={4,700,90,8,67,56,34};
- int f=biggerThenx(x,arrays);
- System.out.println( " there are "+f+" numbers above 56");
- }
- public static int biggerThenx(int b,int[]a){
- int c=0;
- for (int i=0;i<=a.length-1;i++)
- if(a[i]>=b)
- c++;
- return c;
- }
- }
- שאלה 2
- public class aboveOneHundered\4 {
- /**
- *
- */
- public static void main(String[] args) {
- int[]array={100,200,300,400,50,10,700};
- int x=aboveOnehun(array);
- System.out.print("the array has " +x+ " numbers above 100"); }
- public static int aboveOnehun(int[]a)
- {
- int c=0;
- for(int i=0;i<=a.length-1;i++)
- if(a[i]>=100)
- c++;
- return c;
- }
- }
- שאלה 3
- public class threeargu {
- /**
- * @param args
- */
- public static void main(String[] args) {
- int[]arr={45,870,90,78,67,54,77,1001,1,9};
- int n=35;
- boolean f=true;
- int d=checkTruefalse(f,arr,n);
- System.out.println(d );
- // TODO Auto-generated method stub
- }
- public static int checkTruefalse(boolean x,int[]a,int t)
- {
- int c=0;
- for (int i=0;i<=a.length-1;i++)
- {
- if (x==true && a[i]>=t)
- c++;
- else if(x==false && a[i]<=t)
- c++;
- }
- return c;
- }
- }
- שאלה 4
- public class stringMethod\4 {
- /**
- * @param args
- */
- public static void main( String[] args)
- {
- String[] words= new String[5];
- words[0]="Where";
- words[1]="is";
- words[2]="the";
- words[3]="Birthday";
- words[4]="cake?";
- String[]str1= new String[5];
- str1=numberOfwords(words);
- for(int i=0; i<=str1.length-1;i++)
- {
- System.out.print(" "+str1[i]);}
- }
- // TODO Auto-generated method stub
- public static String[] numberOfwords( String[] str )
- {
- for(int i=0;i<=str.length-1;i++)
- {
- if (str[i].length()-1>=4)
- str[i]=str[i].toUpperCase();
- else str[i]=" ";
- }
- return str;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement