• API
• FAQ
• Tools
• Archive
daily pastebin goal
55%
SHARE
TWEET

# Untitled

a guest Oct 11th, 2018 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. public class Lab1 {
2.
3.     public static boolean Ex1_Teen(int a,int b){
4.         int count=0;
5.         if(a>=13 && a<= 19) count++;
6.         if(b>=13 && b<= 19) count++;
7.         if(count==1) return true;
8.         return false;
9.     }
10.
11.     public static int Ex2_Sum(int a,int b, int c){
12.         int sum=0;
13.         if(a==13)return sum;
14.         sum+=a;
15.         if(b==13)return sum;
16.         sum+=b;
17.         if(c==13)return sum;
18.         return sum+=c;
19.     }
20.
21.     public static boolean Ex3_123Seq(int[] array){
22.
23.         for(int i=0;i<array.length-3;i++)
24.             if(array[i]==1)
25.             if(array[i+1]==2)
26.             if(array[i+2]==3)
27.             return true;
28.
29.                 return false;
30.
31.     }
32.
33.     public static void main(String args[]) {
34.         int a=1;
35.         int b=13;
36.         int c=2;
37.         int[] array = {3,2,14,1,2,3,6};
38.
39.         if(Ex1_Teen(a,b))
40.         System.out.println("teen");
41.         System.out.println(Ex2_Sum(a,b,c));
42.
43.         if(Ex3_123Seq(array))
44.         System.out.println("true");
45.
46.     }
47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top