0% found this document useful (0 votes)
7 views4 pages

AnasAbdulrahman Homework

Uploaded by

l3ebsa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

AnasAbdulrahman Homework

Uploaded by

l3ebsa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

package AnasAbdulrahman;

import java.util.Scanner;

public class avaragre {

public static void main(String[] args)


{
Scanner scan = new Scanner(System.in);
int[] a = new int[10];
for(int i =0; i<a.length; i++){
a[i] = scan.nextInt();
}
int sum =0;
for(int i=0; i<a.length; i++){
sum += a[i];
}
double ave = sum/a.length ;
int count = 0;
for(int i =0; i<a.length; i++){
if(a[i] > ave){
count++;
}
}
System.out.println("The avarage = " + ave);
System.out.println(count + " numbers are greater than avarage.");
}
}
package AnasAbdulrahman;

import java.util.Scanner;

public class MaxMinNumbers {


public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int[] numbers = new int[10];

// Read ten numbers from the user


System.out.println("Enter ten numbers:");
for (int i = 0; i < 10; i++) {
numbers[i] = input.nextInt();
}
System.out.print("Entered array: ");
for (int i = 0; i < 10; i++) {
System.out.print(numbers[i] + " ");
}
System.out.println();

// Find the maximum and minimum number


int max = numbers[0];
int min = numbers[0];
for (int i = 1; i < 10; i++) {
if (numbers[i] > max) {
max = numbers[i];
}
if (numbers[i] < min) {
min = numbers[i];
}
}

// Print the maximum and minimum number


System.out.println("Maximum number: " + max);
System.out.println("Minimum number: " + min);
}}
package AnasAbdulrahman;

import java.util.Scanner;
import java.util.Vector;

public class javaapplicationgbh {

public static void main(String[] args) {


Scanner input = new Scanner(System.in);
Vector<String> studentNames = new Vector<String>();
System.out.println("Enter 5 student names:");
for(int i=0; i<5; i++) {
String name = input.nextLine();
studentNames.add(name);
}
System.out.println("The student names are:");
for(String name : studentNames) {
System.out.println(name);
}}}
package AnasAbdulrahman;
import java.util.Stack;

public class javaapplactions2223 {


public static void main(String[] args) {
Stack<Integer> stack = new Stack<>();
// Push 3 elements onto the stack
stack.push(1);
stack.push(2);
stack.push(3);
// Print the elements on the stack
System.out.println("Elements on the stack: " + stack);
// Pop all elements from the stack and print them
while (!stack.isEmpty()) {
System.out.println("Popped element: " + stack.pop());
}
}
}

You might also like