Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package TEST;
- public class lab2 {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- int n= (int)(5+Math.random()*(20-5+1));
- System.out.printf("random number %d \n",n);
- for(int i= 0 ; i<=n;i++) {
- System.out.printf(" %d",i);
- }
- }}
- package TEST;
- import java.util.Scanner;
- public class lab2_task2 {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner sc= new Scanner(System.in);
- int num ;
- num=sc.nextInt();
- for(int r=0;r<num;r++) {
- for(int c=1; c<=num-r;c++ ) {
- System.out.printf(" %d",c );
- }
- // //System.out.println("number"+i );
- System.out.printf("\n");
- }
- }
- }
- package TEST;
- public class lab2_task3 {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- for(int r=150; r>=100;r--) {
- if(r%8==0) { System.out.printf(" %d",r );
- }
- }
- }
- }
- package TEST;
- public class lab2_task4 {
- public static void main(String[] args) {
- int n= (int)(1990+Math.random()*(2020-1990+1));
- //int n=2016;
- System.out.println("random year ="+n);
- if(n%4==0) {
- if(n%4==0 && n%100!=0) {
- System.out.printf("%d : true ",n);
- }else{System.out.printf("%d : false ",n);}
- }else System.out.printf("%d : false ",n);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement