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

Lab 3

The document outlines Lab 3 for the CS 212 Object Oriented Programming course, focusing on arrays in Java. It includes tasks such as creating a sales report application, inputting unique numbers, simulating dice rolls, developing a grade management system, and building a currency converter. Each task emphasizes the use of arrays and requires specific functionalities to be implemented in Java.

Uploaded by

sadax16031
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)
21 views4 pages

Lab 3

The document outlines Lab 3 for the CS 212 Object Oriented Programming course, focusing on arrays in Java. It includes tasks such as creating a sales report application, inputting unique numbers, simulating dice rolls, developing a grade management system, and building a currency converter. Each task emphasizes the use of arrays and requires specific functionalities to be implemented in Java.

Uploaded by

sadax16031
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

Department of Computing

CS 212: Object Oriented Programming


BESE15AB
Spring 2025
Lab 3: Arrays in Java
Date: 17-02-2025
Instructor: Ms. Mehwish Kiran
Lab Engineer: Ms. Shakeela Bibi

CS 212: Object Oriented Programming Page 1


Lab 03: Arrays in Java

Objective: The primary objective of this lab is to provide you with a solid understanding of the
following key concepts:

• Variable length arguments and their usage in Java.


• Use of Arrays in Java
Tools/ Software: VS Code, NetBeans, Eclipse etc.

Task 1:

Design a java application for the Sales Department which wants to generate a report that
calculates the total revenue from multiple sales entries for each month, allowing flexibility in the
number of inputs. The system should accept the name of the month and a variable number of
sales as double values and generate a formatted report displaying each entry of month along with
the total sales. Since the number of revenue sources may vary each month, the implementation
should be able to dynamically handle different numbers of sales figures without requiring
overloaded methods. The report should ensure precise financial calculations and provide a clear,
professional output.

Sample Output:

CS 212: Object Oriented Programming Page 2


Task 2:

Write an application that inputs five numbers, each between 10 and 100, inclusive. As each number
is read, display it only if it’s not a duplicate of a number already read. Provide for the “worst case,”
in which all five numbers are different. Use the smallest possible array to solve this problem.
Display the complete set of unique values input after the user enters each new value.

Task 3:

Write an application to simulate the rolling of two dice. The application should use an object of
class Random once to roll the first die and again to roll the second die. The sum of the two
values should then be calculated. Each die can show an integer value from 1 to 6, so the sum of
the values will vary from 2 to 12, with 7 being the most frequent sum, and 2 and 12 the least
frequent. Figure below shows the 36 possible combinations of the two dice. Your application
should roll the dice 36,000,000 times. Use a one-dimensional array to tally the number of times
each possible sum appears. Display the results in tabular format.

Task 4:

A university wants to develop a Grade Management System to store and analyze students' grades
across multiple subjects. Each student is enrolled in multiple courses, and their grades for
different assignments or exams need to be recorded and processed efficiently. The system should
use a multi-dimensional array to store student grades, calculate the average grade per student,
and identify the top-performing student in the class.

Store student grades in a 2D array, where rows represent students and columns represent grades
in different subjects. Allow the system to calculate the average grade for each student. Identify
the top-performing student based on their average grade. Display a formatted report of students'
grades and their performance analysis. Use separate methods to calculate average, displaying
grades and finding top student.

CS 212: Object Oriented Programming Page 3


Task 5:

Create a financial application in Java which requires a Currency Converter that allows users to
convert an amount from one currency to another using command-line arguments. The system
should accept the amount, source currency, and target currency as input and return the converted
amount based on predefined exchange rates.

Requirements:

• Accept three command-line arguments:


• Amount (double) → The amount to be converted.
• Source Currency (String) → The currency code of the original amount (e.g., "USD").
• Target Currency (String) → The currency code to convert into (e.g., "EUR").
• Validate the input to ensure the amount is a valid number and the currency codes are
recognized.
• Use predefined exchange rates for conversion (e.g., USD to EUR = 0.91, USD to INR =
83.0, etc.).
• Perform the currency conversion based on the exchange rate provided.
• Display the converted amount in a properly formatted manner.

Deliverables: Submit a single file on LMS before the due date as communicated by Lab
Engineer. Please attempt the lab quiz at the defined time.

Note: Write your registration number and name at the top of each code. You will submit your
working codes and outputs (Just Screenshots) in the Lab Report.

CS 212: Object Oriented Programming Page 4

You might also like