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

Assignment Question 2 243 CSE1116 H AAU

The document outlines three programming assignments: the first requires calculating product profits from an input file while handling various exceptions, the second involves tracking student grades using an ArrayList and providing methods for grade management, and the third task is to separate student IDs from a file into odd and even ID files. Each assignment specifies input/output requirements and exception handling. The document emphasizes the importance of file management and user interaction in the implementations.

Uploaded by

nazhatarannum090
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 views3 pages

Assignment Question 2 243 CSE1116 H AAU

The document outlines three programming assignments: the first requires calculating product profits from an input file while handling various exceptions, the second involves tracking student grades using an ArrayList and providing methods for grade management, and the third task is to separate student IDs from a file into odd and even ID files. Each assignment specifies input/output requirements and exception handling. The document emphasizes the importance of file management and user interaction in the implementations.

Uploaded by

nazhatarannum090
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/ 3

Assignment 2

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:

Max Profit Item :

Exception Handling:

- Handle All file IO Exception

- If any of the price is less than zero then throw InvalidPriceException.

- If TotalUnitSold is less than Zero then throw TotalUnitSoldMnimumBoundException.

- If TotalUnitSold is greater than 1000 then throw TotalUnitSoldMaximumBoundException

- Create ncecessary custom Exception classes

- Close all file after the completion of operation

……………………………………………
AnnualSell.txt

Item UnitCost UnitSellingPrice TotalUnitSold

Pen 8 10 500

Paper 8.5 10 450

File 50 55 100

Java Book 250 -260 75

Mouse 300 298 65

Ruler 5.5 6 600

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

You might also like