0% found this document useful (0 votes)
9 views

Java Project

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Java Project

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Rainfall Report Automation

Java Project

Version 1.0
Prepared By / Last
Reviewed By Approved By
Updated By

Name

Role

Signature

Date
Table of Contents

1.0 Introduction 3

1.1 Purpose 3

1.2 Definitions & Acronyms 3

1.3 Project Overview 3

1.4 Scope 3

1.5 Target Audience 4

1.6 Hardware and Software Requirements 4

1.6.1 Hardware Requirements 4


1.6.2 Software Requirements 4

2.0 Functional Requirements 4

2.1 Functional Requirements 4

2.2 Use case Diagram 5

2.3 System Architecture Diagram 6

3.0 Design Specification 6

3.1 Data Design 6

3.2 Component Design for identified Use cases 7

3.2.1 Parse data and generate the average annual rainfall for all the cities 7
3.2.2 Extract the names of the cities with heavy rainfall 11

3.3 General Design Constraints 12

4.0 Submission 12

4.1 Code submission instructions 12

5.0 Change Log 12


1.0 Introduction
1.1 Purpose of this document
The Meteorological Department did an analysis of the rainfall in different cities
over a period of one year. They had a bunch of records which had the average
monthly rainfall of every month in all those cities. As a result of their analysis,
they needed to generate a report of the cities which received heavy rainfall by
calculating the average annual rainfall based on each city manually. To do away
with the manual tasks, they now want to automate all the above-mentioned
processes. Help them to automate this report generation process.

The Meteorological Department has the following tasks that must be automated.

1. Parse data and calculate the average annual rainfall of all the cities

Extract the names of the cities with heavy rainfall

1.2 Definitions & Acronyms


Definition / Acronym Description

Nil

1.3 Project Overview


This project captures the various concepts, techniques and skills learned and
help to put them into practice using Java with JDBC which a software engineer
must be good at. Admittedly, this would be at a scaled-down level since the
purpose is to let the associate experience the various concepts learned in Java
as an individual. The individual associate is expected to carry out the knock out
challenge and complete it within 4 hours.

1.4 Scope
The scope of the system is explained through its following modules

1. Parse data and calculate the average annual rainfall of all cities

2. Extract the names of the cities with heavy rainfall


1.5 Target Audience
Learner Level

1.6 Hardware and Software Requirements


1.6.1 Hardware Requirements
# Item Specification/Version

1.6.2 Software Requirements


# Item Specification/Version

1. Java 8

2. MYSQL 5.1

Note: All the required hardware and software is provided in the TekStac platform

2.0 Functional Requirements


2.1 Functional Requirements
Req. # Req. Name Req. Description Actors / Comments
Users

1 Parse data The average monthly rainfall Admin The admin of the
and in each city and the other meteorological
calculate details of the city are stored department is
the average in a flat file. Retrieve the data responsible for
annual from the file and calculate parsing the data and
rainfall of all the average annual rainfall calculating the
cities for each city based on its average annual
monthly rainfall. rainfall for all the
cities
2 Extract the The average annual rainfall of Admin The admin of the
names of the each city is stored in the meteorological
cities with database, the meteorological department is
heavy rainfall department will find the responsible for
maximum rainfall value and retrieving the average
display the city details which annual rainfall of each
has the maximum rainfall city from the
from the database. database and
Identifying the cities
with the maximum
rainfall

2.2 Use case Diagram


2.3 System Architecture Diagram

3.0 Design Specification


3.1 Data Design
Table Structure:

Table name: AnnualRainfall


Column Name Data type
city_pincode number
city_name varchar
average_annual_rainfall double

Design Constraints:
 Use MYSQL database to store the data. The database name should be
“RainfallReport”.

 The above table has been already created. To create the table in your
local machine, the script is available in “script.sql” . The table names and
the column names should be the same as specified in the table
structure.

 Database connections should be configurable; it should not be hard


coded. The database information is specified in the “db.properties” file,
which is also provided as part of the code skeleton.

3.2 Component Design for identified Use cases


3.2.1 Parse data and generate the average annual rainfall for all
cities
The average monthly rainfall in each city and the other details of the city are stored
in a flat file. Retrieve the data from the file and calculate the average annual rainfall
of each city based on its monthly rainfall. The details of the cities with the rainfall
details are stored in a file named AllCityMonthlyRainfall.txt.

Sample File containing rainfall details. The file is comma delimited.

[AllCityMonthlyRainfallFormat:
cityPincode,cityName,JanRainfall,FebRainfall,MarRainfall,AprRainfall,MayRainfall,Ju
nRainfall,JulRainfall,AugRainfall,SepRainfall,OctRainfall,NovRainfall,DecRainfall]

From the AllCityMonthlyRainfall.txt file, read the details, parse the data and
construct an AnnualRainfall object for each record in the file, then calculate the
averageAnnualRainfall of each city based on the conditions mentioned below:
Average Annual Rainfall = (sum of all monthly rainfall of a city)/number of months

For example: If the city has a monthly rainfall as

30, 15.5, 12, 10, 15, 20.9, 21, 22, 20, 18.6, 15, 10

then the averageAnnualRainfall will be

(30+15.5+12+10+15+20.9+21+22+20+18.6+15+10)/12, which is 210/12 = 17.5

Therefore, the averageAnnualRainfall of that city is 17.5

After calculating the averageAnnualRainfall, store all the AnnualRainfall object into
a list.

Validation:

The city Pincode should contain exactly 5 digits. If the city Pincode is valid then
parse the data and calculate the average annual rainfall else throw a user defined
Exception “InvalidCityPincodeException” with a message "Invalid City Pincode".

Component Specification: AnnualRainfall(model class)

Compo Type(Class) Attributes Methods Responsi


nent bilities
Name

Parse AnnualRainfall int cityPincode Include getters


data and setter
and String cityName method for all
calculat the attributes.
e the double
average averageAnnualRainfall
annual
rainfall
of all
cities

Parse AnnualRainfall void This


data calculateAvera method
and geAnnualRainf should
calculat all (double calculate
e the monthlyRainfa and set the
average ll [ ] ) averageAn
annual nualRainfal
rainfall l based on
of all the
cities monthly
rainfall
the city
received

RainfallReport(utility class)

Compo Type(Class) Method Responsibi Exception


nent lities
Name

Parse RainfallReport List<AnnualRainfall>ge This


data nerateRainfallReport(S method
and tring filePath) takes the
calculat file path as
e the argument
average and it
annual should
rainfall parse the
of all data stored
cities in the file
and it
should
validate the
city Pin
code by
invoking
the
validate()
method, if
valid,
construct
an
AnnualRainf
all object
for each
record in
the file,
then
calculate
the average
annual
rainfall by
invoking
the
calculateAv
erageAnnua
lRainfall(do
uble
monthlyRai
nfall [])
method of
AnnualRainf
all class.
After
calculating
the
averageAnn
ualRainfall,
each
AnnualRainf
all should
be added
into the list
and this
method
should
return the
list of
AnnualRainf
all.
Parse RainfallReport boolean validate(String This method Throw a user
data cityPincode) should defined
and validate the exception
calculat city pincode, “Invalid
e the if valid CityPincode
average return true Exception” if
annual else this the pincode
rainfall method is invalid.
of all should throw
cities an
userdefined
exception
Note: The data file will contain both valid and invalid details. Valid rainfall details
should be added to the list and for the invalid ones, user defined exception should
be thrown.
3.2.2 Extract the names of the cities with heavy rainfall
The averageAnnualRainfallof each city is stored in the database, the meteorological
department will find the maximumRainfall value and display the city details which
received the maximumRainfall from the database.

Component Specification:

RainfallReport(utility class)

Compon Type(Clas Method Responsibilities Resource


ent s) s
Name

Extract RainfallRe List<AnnualRainfall> This method MYSQL


the port findMaximumRainfa should extract all database
names of llCities () the is used.
the cities AnnualRainfall Retrieve
with details from the the details
heavy AnnualRainfall from
rainfall table and return AnnualRai
the list of cities nfall table
with maximum
averageAnnualRa
infall.

Connect to the
database by
invoking the
establishConnecti
on() method of
DBHandler class.

DBHandler(DAO class)

Compone Type(Clas Method Responsibiliti Resources


nt Name s) es

Extract the DBHandler Connection This method MYSQL


names of establishConnectio should connect database is
the cities n() to the used. Store
with heavy database by and retrieve
rainfall reading the the details
database into/from
details from AnnualRainf
the all table.
db.properties
file and it db.propertie
should return s file is used
the connection for storing
object the
database
details.

3.3 General Design Constraints


1. The attribute/method/class name should be correctly specified as given in
the document.

2. Do not hardcode the database configuration details in the DBHandler class,


read it from the db.properties file.

4.0 Submission
4.1 Code submission instructions
1. Do not change the code skeleton given, as your code will be auto
evaluated.

2. You can validate your solution against sample test cases during the
assessment duration.

3. Your last submitted solution will be considered for detailed evaluation.

4. Make sure to submit the solution before the specified time limit. You will
not be allowed to submit the solution once the mentioned time for the
assessment is over.

5.0 Change Log


Changes Made
V1.0.0 Initial baseline created on <dd-Mon-yy> by <Name of Author>
Vx.y.z <Please refer to the configuration control tool / change item status form if the
details of changes are maintained separately. If not, the template given below
needs to be followed>
Section Changed Effective Changes Effected
No. By Date

You might also like