//homework1 System.out.println("How many numbers? "); int num = scan.nextInt(); System.out.println("enter numbers"); int number=0; int max=0; int i=0; while(i<num) { max=number; number = scan.nextInt(); if(number>max) { max=number; } else { number=max; } i++; } System.out.println("the max number= "+max); Scanner scanner = new Scanner(System.in); System.out.print("Enter the first integer: "); int start = scanner.nextInt(); System.out.print("Enter the second integer: "); int end = scanner.nextInt(); printPrimeNumbers(start, end); } private static boolean isPrime(int number) { if (number <= 1) { return false; } for (int i = 2; i <= Math.sqrt(number); i++) { if (number % i == 0) { return false; } } return true; } private static void printPrimeNumbers(int start, int end) { for (int i = start; i <= end; i++) { if (isPrime(i)) { System.out.print(i + " "); } } System.out.println(); } //homework5 Scanner scan = new Scanner(System.in); System.out.print("Enter a non-negative integer: "); int number = scan.nextInt(); long factorial = 1; for (int i = 1; i <= number; i++) { factorial *= i; } System.out.println("Factorial of " + number + " = " + factorial); //homework8 Scanner scan = new Scanner(System.in); System.out.print("Enter R : "); int R= scan.nextInt(); int loop=0; do { System.out.println(loop*4); loop += 2; }while(loop<R); }} //homework9 int z=0; Scanner scan = new Scanner(System.in); for(int i=0;i<5;i++) { for(int j=0;j<10;j++) { z=i+2*j; } } System.out.print(z); //homework10(a) for(int i =0;i<5;i++) { for(int j=0;j<=i;j++) { System.out.print('*'); } System.out.print('\n'); } //homework10(c) for(int i =0;i<5;i++) { for(int j=4;j>=i;j--) { System.out.print('*'); } System.out.print('\n'); }