PROBBLEM #1
Abias,Maria Michaella Mae
Write a Java program that:
1. Asks the user how many students are in the class.
2. Reads all the students’ scores into an array.
3. Determines the best score among them.
4. Assigns a grade to each student based on the following rules:
● Grade A: score ≥ best − 10
● Grade B: score ≥ best − 20
● Grade C: score ≥ best − 30
● Grade D: score ≥ best − 40
● Grade F: otherwise
5. Displays each student’s index (Student 0, Student 1, …), their score, and their grade
Sample Run
Enter the number of students: 5
Enter 5 scores:
85
78
92
65
55
Student 0 score is 85 and grade is B
Student 1 score is 78 and grade is C
Student 2 score is 92 and grade is A
Student 3 score is 65 and grade is D
Student 4 score is 55 and grade is F
The best score = 92.
PROBLEM #2
Adante,John Rich
Problem Statement
Write a Java program that:
1. Continuously reads integers between 1 and 100 from the user.
2. Counts how many times each number occurs.
3. Stops reading input when the user enters 0 (zero).
4. Displays the occurrence count for each number that appears at least once.
Sample Run
Enter numbers between 1 and 100 (end with 0):
2 5 6 5 4 3 23 43 2 0
2 occurs 2 times
3 occurs 1 time
4 occurs 1 time
5 occurs 2 times
6 occurs 1 time
23 occurs 1 time
43 occurs 1 time
PROBLEM #3 Adranida,Aljhon Lloyd
Problem Statement
Write a Java program that:
1. Reads an unspecified number of student scores (integers).
2. Stores the scores in an array (with a maximum of 100 scores).
3. Stops reading input when the user enters a negative number.
4. Computes the average score.
5. Determines and displays:
o How many scores are greater than or equal to the average
o How many scores are below the average
Enter scores (negative number to end):
70 90 85 60 100 75 -1
Average score = 80.00
Number of scores >= average: 4
Number of scores < average: 2
PROBLEM #4 Celeste,Gabriel
Problem Statement
Write a Java program that:
1. Reads ten numbers from the user.
2. Stores only the distinct numbers (ignores duplicates).
3. After input, displays:
o The number of distinct numbers entered.
o The distinct numbers, separated by exactly one space.
Hint:
● When reading each number, check if it already exists in the
array.
● If it does not exist, store it.
● If it exists, ignore it.
Sample Run
Enter 10 numbers:
1232163452
The number of distinct numbers is 6
The distinct numbers are: 1 2 3 6 4 5
PROBLEM #5 Custodio,John Vic
Problem Statement
Write a Java program that:
1. Generates 100 random integers between 0 and 9.
2. Uses an array of size 10 (counts[0] to counts[9]) to keep
track of how many times each digit occurs.
3. Displays the count for each number 0–9 after all random
numbers are generated.
Hint:
● Use [Link]() or Random class to generate numbers.
● If a random number n is generated, increment counts[n].
Sample Run
0 occurs 8 times
1 occurs 12 times
2 occurs 7 times
3 occurs 9 times
4 occurs 10 times
5 occurs 11 times
6 occurs 14 times
7 occurs 12 times
8 occurs 9 times
9 occurs 8 times
PROBLEM #6 - Donieto,Carlo
A local baseball team wants to computerize its records. The team
has 20 players, identified by numbers 1 through 20.
For each game, the team records each player’s performance in the
format:
playerID hits walks outs
● playerID → number from 1 to 20
● hits → number of successful hits in that game
● walks → number of times the player walked (does not count as
an at-bat)
● outs → number of times the player was out
Example input line:
3211
This means Player #3 had:
● 2 hits,
● 1 walk,
● 1 out.
➡ Total appearances = 2 + 1 + 1 = 4.
➡ At-bats = hits + outs = 3 (walks excluded).
➡ Batting average = hits ÷ at-bats = 2 ÷ 3 = 0.667.
The user will enter several records (one per line). Input ends when
the user enters -1 as the player ID.
The program must compute and display a table showing for each
player:
1. Player’s ID
2. Batting average (3 decimal places)
3. Number of walks
Note: Player IDs are 1–20, but Java arrays start at index 0.
Sample Run
User Input
Enter player records (playerID hits walks outs). Enter -1 to stop:
3211
3102
1101
2220
1012
-1
Program Output
Player Batting Avg Walks
1 0.333 1
2 1.000 2
3 0.500 1
4 0.000 0
5 0.000 0
...
20 0.000 0
PROBLEM #7 Estomata,Jullian
-
Design, implement, and test a Java program that calculates the mean and standard
deviation of integers entered from the keyboard.
● The user first enters how many integers they want to process.
● Then the user enters each integer, one by one.
● The program computes:
●
● The program should output the mean and standard deviation as float values,
properly labeled.
Sample Run
Input
Enter the number of integers: 5
Enter integer 1: 10
Enter integer 2: 12
Enter integer 3: 23
Enter integer 4: 23
Enter integer 5: 16
Step-by-step Calculation
● Numbers: 10, 12, 23, 23, 16
● Mean = (10 + 12 + 23 + 23 + 16) / 5 = 84 / 5 = 16.8
● Differences from mean:
o (10 − 16.8)² = 46.24
o (12 − 16.8)² = 23.04
o (23 − 16.8)² = 38.44
o (23 − 16.8)² = 38.44
o (16 − 16.8)² = 0.64
● Sum of squared differences = 146.8
● Divide by (N − 1) = 146.8 / 4 = 36.7
● Standard deviation = √36.7 ≈ 6.059
Output
Mean = 16.800
Standard Deviation = 6.059
PROBLEM #8 Evasco,Joseph Benedict
Your history professor has a large class (up to 100 students) and wants to analyze exam
performance. You are asked to write an application that performs some statistical
analyses on the exam scores.
Program Requirements
1. The program should read the number of students from the user.
2. Then read each student’s test score (0–100) from the keyboard.
3. Compute:
o Class mean (average score)
o Standard deviation (same formula as in Problem 2)
o Percentage of students falling into each score range:
▪ < 10
▪ 10–19
▪ 20–29
▪ 30–39
▪ 40–49
▪ 50–59
▪ 60–69
▪ 70–79
▪ 80–89
▪ ≥ 90
4. Print a summary report showing:
o Mean
o Standard deviation
o A histogram (text-based) of the percentage distribution of scores.
Sample Run
Input
Enter number of students: 10
Enter score for student 1: 95
Enter score for student 2: 82
Enter score for student 3: 67
Enter score for student 4: 54
Enter score for student 5: 45
Enter score for student 6: 76
Enter score for student 7: 89
Enter score for student 8: 92
Enter score for student 9: 38
Enter score for student 10: 15
Step-by-step Summary
● Scores = [95, 82, 67, 54, 45, 76, 89, 92, 38, 15]
● Mean = 65.3
● Standard deviation ≈ 25.5
● Distribution (percentages):
o <10: 0%
o 10–19: 10%
o 20–29: 0%
o 30–39: 10%
o 40–49: 10%
o 50–59: 10%
o 60–69: 10%
o 70–79: 10%
o 80–89: 20%
o ≥90: 20%
Output
Class Statistics
----------------
Mean = 65.300
Standard Deviation = 25.500
Score Distribution:
<10 :
10 - 19 : *
20 - 29 :
30 - 39 : *
40 - 49 : *
50 - 59 : *
60 - 69 : *
70 - 79 : *
80 - 89 : **
90 - 100 : **
PROBLEM #9 Guiruela,Roniel
Reconstructed Problem
Your professor asks you to create a program that will store the exam scores of students
using an array.
● The program should first ask how many students took the exam.
● It should then accept the scores of each student one by one with a prompt.
● After collecting all scores, the program should compute the average score.
● Finally, it should display the computed average to the user.
Sample Run
Enter number of students: 5
Enter score of student 1: 90
Enter score of student 2: 85
Enter score of student 3: 78
Enter score of student 4: 92
Enter score of student 5: 88
The average score is: 86.6
PROBLEM 10 Laure,Troy
A weather station records the daily temperatures for 7 days of the week.
● The program should prompt the user to enter the temperature for each day (e.g.,
Enter temperature for Monday:).
● The program will store these values in an array.
● After all inputs are entered, the program should determine and display:
o The highest temperature recorded.
o The lowest temperature recorded.
Sample Run
Enter temperature for Monday: 32
Enter temperature for Tuesday: 30
Enter temperature for Wednesday: 28
Enter temperature for Thursday: 33
Enter temperature for Friday: 29
Enter temperature for Saturday: 31
Enter temperature for Sunday: 34
Highest temperature: 34
Lowest temperature: 28
PROBLEM 10 Madera,Mark Anthony
A small shop records the sales amount and product name of
several products.
● The program should first ask how many products are being
recorded.
● For each product, the program will ask the user to enter the
product name and its sales amount.
● The program will store this information in arrays (one for
product names, one for sales).
● After all inputs are entered, the program should:
1. Display the total sales of all products.
2. Identify and display the product with the maximum
sales.
Sample Run
Enter number of products: 4
Enter product name for product 1: Soap
Enter sales for Soap: 120
Enter product name for product 2: Shampoo
Enter sales for Shampoo: 300
Enter product name for product 3: Toothpaste
Enter sales for Toothpaste: 250
Enter product name for product 4: Detergent
Enter sales for Detergent: 180
Total sales: 850
Product with maximum sales: Shampoo (300)
PROBLEM 11 Martinez,John Rey
‘
A teacher records the answers of a multiple-choice exam taken by students.
● The program should first ask the user to enter the number of students.
● Then, it should ask the user to input the answer of each student
(choices: A, B, C, or D).
● The program will store all the answers in an array.
● After collecting all responses, the program should calculate and display
the percentage of students who selected each answer (A, B, C, D).
Sample Run
Enter number of students: 5
Enter answer of student 1: A
Enter answer of student 2: C
Enter answer of student 3: B
Enter answer of student 4: A
Enter answer of student 5: D
Percentage of answers:
A: 40.0%
B: 20.0%
C: 20.0%
D: 20.0%
PROBLEM 12 Purisima,Mark Jan
A library wants to track how many times books were borrowed in a
month.
● The program should first ask the user to enter the number of
books to be tracked.
● For each book, the program should ask the user to enter the
book title and the number of times it was borrowed.
● Store the titles and borrow counts in arrays.
● After all inputs are entered, the program should display:
o The book borrowed the most.
o The book borrowed the least.
Sample Run
Enter number of books to be tracked: 4
Enter title of book 1: Harry Potter
Enter times borrowed: 25
Enter title of book 2: The Hobbit
Enter times borrowed: 15
Enter title of book 3: Noli Me Tangere
Enter times borrowed: 32
Enter title of book 4: Math Workbook
Enter times borrowed: 10
Book borrowed the most: Noli Me Tangere (32)
Book borrowed the least: Math Workbook (10)
PROBLEM 13 Rabosa,Adrian
Reconstructed Problem
A city records the rainfall (in millimeters) for 12 months of the year.
● The program should prompt the user to enter the rainfall amount for each month,
one by one, with the corresponding month name.
● Store these rainfall values in an array.
● After input is complete, the program should:
1. Compute and display the average rainfall.
2. Display the month with the least rainfall.
3. Display the month with the most rainfall.
Sample Run
Enter rainfall for January: 120
Enter rainfall for February: 80
Enter rainfall for March: 95
Enter rainfall for April: 110
Enter rainfall for May: 150
Enter rainfall for June: 200
Enter rainfall for July: 250
Enter rainfall for August: 300
Enter rainfall for September: 220
Enter rainfall for October: 180
Enter rainfall for November: 140
Enter rainfall for December: 100
Average rainfall: 162.9
Month with least rainfall: February (80)
Month with most rainfall: August (300)
PROBLEM 14 Rey,Emil
Create a program that stores the name, age, and section of 5 students.
● The program should use three separate arrays:
o One for student names
o One for student ages
o One for student sections
● After storing the details, the program should display all the student records in
reverse order of entry (starting from the last student entered down to the first).
Sample Run
Enter name of student 1: John
Enter age of student 1: 18
Enter section of student 1: A
Enter name of student 2: Maria
Enter age of student 2: 19
Enter section of student 2: B
Enter name of student 3: Peter
Enter age of student 3: 20
Enter section of student 3: A
Enter name of student 4: Anna
Enter age of student 4: 18
Enter section of student 4: C
Enter name of student 5: Mark
Enter age of student 5: 19
Enter section of student 5: B
--- Student Records in Reverse Order ---
Name: Mark Age: 19 Section: B
Name: Anna Age: 18 Section: C
Name: Peter Age: 20 Section: A
Name: Maria Age: 19 Section: B
Name: John Age: 18 Section: A
PROBLEM 15 Rey Jr,Edgar
Reconstructed Problem
A student has failed in several subjects but is given a chance to retake the exams.
● The program should first ask the user to input the number of subjects the student
failed.
● For each subject, the program should then ask the user to input:
1. The old score (before retake).
2. The new score (after retake).
● The program should calculate and display the improvement for each subject.
Sample Run
Enter number of subjects failed: 3
Enter old score for subject 1: 45
Enter new score for subject 1: 70
Enter old score for subject 2: 50
Enter new score for subject 2: 80
Enter old score for subject 3: 40
Enter new score for subject 3: 65
--- Improvement Report ---
Subject 1: Old = 45, New = 70, Improvement = 25
Subject 2: Old = 50, New = 80, Improvement = 30
Subject 3: Old = 40, New = 65, Improvement = 25
Write a program to create an array of 25 integers. The program should:
a) Print all 25 numbers on one line.
b) Print the numbers, 5 per line.
c) Print the numbers in reverse order (from 25th to 1st).
d) Print every 5th number in the array.
e) Print the average of the 25 numbers.
f) Print the largest and the smallest number.
g) Print all numbers greater than the average.
💻 Sample Run
(Assume the 25 numbers are from 1 to 25 for demonstration)
Array elements:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
5 numbers per line:
12345
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
Numbers in reverse order:
25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
Every 5th number:
5 10 15 20 25
Average of numbers: 13.0
Smallest number: 1
Largest number: 25
Numbers greater than average:
14 15 16 17 18 19 20 21 22 23 24 25
PROBLEM 17 Teaño,Xian Tristan
Write a program that assigns grades to students based on their
exam scores.
● First, the program asks the user to enter the number of
students.
● Then, the program asks for the scores of all the students.
● It finds the best (highest) score among all students.
● Grades are assigned based on this scheme:
o A: score ≥ best − 10
o B: score ≥ best − 20
o C: score ≥ best − 30
o D: score ≥ best − 40
o F: otherwise
● Finally, the program displays each student’s score along
with the assigned grade.
Sample Run
Enter number of students: 4
Enter score for student 1: 85
Enter score for student 2: 78
Enter score for student 3: 95
Enter score for student 4: 66
Best score: 95
Student 1 score is 85 and grade is B
Student 2 score is 78 and grade is C
Student 3 score is 95 and grade is A
Student 4 score is 66 and grade is D
PROBLEM 18 Torres,Jefferson
Write a program that reads integers between 1 and 100 from the
user.
● The input ends when the user enters 0.
● The program should count how many times each number
occurs.
● After input ends, the program should display the counts for the
numbers that actually appeared.
Sample Run
Enter numbers between 1 and 100 (end with 0):
2 5 6 5 4 3 23 43 2 0
Occurrences:
2 occurs 2 times
3 occurs 1 time
4 occurs 1 time
5 occurs 2 times
6 occurs 1 time
23 occurs 1 time
43 occurs 1 time
PROBLEM 19 Tumaob,Joemare
Write a program that processes student scores.
● The program will read scores one by one.
● Input ends when the user enters a negative number.
● Store all the scores in an array (maximum of 100 scores).
● Compute the average score.
● Count and display:
o How many scores are greater than or equal to the
average.
o How many scores are below the average.
Sample Run
Enter scores (negative number to end):
80
90
70
60
50
-1
Average score = 70.0
Number of scores >= average: 3
Number of scores < average: 2
PROBLEM 20 Zape,John Arven
Write a program that:
● Generates 100 random integers between 0 and 9.
● Uses an array of size 10 (index 0 → count of 0s, index 1 → count
of 1s, … index 9 → count of 9s).
● After generating all numbers, display how many times each
digit occurred.
Sample Run
(Random numbers will vary, but here’s an example output)
Digit counts after generating 100 random numbers (0–9):
0 occurs 7 times
1 occurs 8 times
2 occurs 11 times
3 occurs 12 times
4 occurs 9 times
5 occurs 13 times
6 occurs 10 times
7 occurs 12 times
8 occurs 9 times
9 occurs 9 times