Assignment Question 2 243 CSE1116 H AAU
Assignment Question 2 243 CSE1116 H AAU
Question 1. Write a program to calculate the profit for each product. The product list and corresponding
information can be found in the given input file "AnnualSell.txt". Write output to "Profit.txt" file in the
following format: 10
Item Profit
... ....
... ....
Total Profit:
Exception Handling:
……………………………………………
AnnualSell.txt
Pen 8 10 500
File 50 55 100
Pencil 7 7.5 45
Question 2. 5
You are tasked with creating a program to track the grades of students in a class. Implement a Java program
that does the following:
● Define an ArrayList to store the grades of students (integer values).
● Write a method called addGrade that takes an integer (student's grade) as input and adds
it to the ArrayList.
● Implement a method named calculateAverage that calculates and returns the average
grade of all the students.
● Create a method called highestGrade that finds and returns the highest grade in the
ArrayList.
● Design a function named listPassingStudents that prints the grades of students who have
passed (grades >= 50).
● Write a main method to demonstrate the functionality of your program. Prompt the user
to input grades until -1 is entered by the user, then display the average grade, highest grade, and list of
passing students.
Question 3: 5
Suppose you have a file “id.txt” that contains the ids of multiple UIU students. Write a java code to write
the odd ids in the id.txt file to another file called “odd.txt” and the even ids in the id.txt file to another file
called “even.txt”. Check the following example for clarification