LAB ASSIGNMENT 8
PROGRAMMING FUNDAMENTAL
Submitted to:
MAM HAFIZA SUNDAS FAROOQ
Submitted by:
MUHAMMAD TALHA( SP24-BSE-037)
TASK 1:
public class task1 {
public static void main(String[] args) {
System.out.println("Each student, enter your rating from 1 to 10
(40 ratings total):");
int[] responses = {
7, 8, 5, 9,
6, 4, 7, 8,
5, 6, 6, 7,
8, 9, 7, 10,
6, 5, 4, 6,
5, 7, 8, 6,
9, 8, 7, 6,
7, 6, 6, 8,
5, 5, 7, 6,
8, 9, 7, 6
};
int maxRating = 0; // Ratings 7 to 10
int medium = 0; // Ratings 4 to 6
int worse = 0; // Ratings 1 to 3
for (int elements : responses) {
if (elements >= 7) {
maxRating++;
} else if (elements >= 4) {
medium++;
} else {
worse++;
System.out.println("Summary of Ratings:");
System.out.println("High Ratings (7-10): " + maxRating);
System.out.println("Medium Ratings (4-6): " + medium);
System.out.println("Low Ratings (1-3): " + worse);
}
}
TASK 2:
public class task2 {
public static void modify (int [] array) {
for (int i = 0; i < array.length; i++) {
array[i] = array[i] * 3;
public static void main(String[] args) {
int [] array = {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10};
modify(array);
for (int elements : array) {
System.out.print(elements + " ");
TASK 3:
public class task3 {
public static void main(String[] args) {
int[] array1 = {1, 2, 3, 4, 5};
int[] array2 = new int[array1.length];
for (int i = 0; i < array1.length; i++) {
array2[i] = array1[array1.length - 1-i];
for (int element : array2) {
System.out.println(element);