0% found this document useful (0 votes)
4 views7 pages

Spring 2025 - CS506 - 2

This assignment requires students to create a Java project named SalesPrediction that involves designing a GUI, connecting to a database, and performing CRUD operations on sales data. Students must implement features such as adding data points, loading data, deleting records, training a model, and predicting sales based on user input. Submissions must be in a specified compressed format and adhere to strict guidelines regarding content and deadlines.

Uploaded by

umerasad744
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)
4 views7 pages

Spring 2025 - CS506 - 2

This assignment requires students to create a Java project named SalesPrediction that involves designing a GUI, connecting to a database, and performing CRUD operations on sales data. Students must implement features such as adding data points, loading data, deleting records, training a model, and predicting sales based on user input. Submissions must be in a specified compressed format and adhere to strict guidelines regarding content and deadlines.

Uploaded by

umerasad744
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/ 7

Assignment No.

02
Total Marks: 20
Semester: Spring 2025
Due Date: June 23, 2025
CS506 – Web Design and Development

Please read the following instructions carefully before solving & submitting assignment:

Uploading Instructions:

 You may use any IDE of your choice (e.g., NetBeans, IntelliJ IDEA, etc.) to complete this assignment.
 Create a new project in your IDE and name it SalesPrediction.
 Your submission must include the entire project folder, containing all relevant files such as: Source code (.java files), Database
files, GUI forms and Build files etc.
 Once completed, compress the entire project folder into a .zip or .rar file and name it as SalesPrediction.zip or SalesPrediction.rar.
 Only include the Java project files. Do not include unrelated content (like assignment file, screenshots and documentation etc.).
 Ensure the file extension is correct. Submissions with incorrect file types will not be accepted.
o Accepted: SalesPrediction.zip, SalesPrediction.rar

o Not accepted: SalesPrediction.txt, SalesPrediction.java, SalesPrediction.docx


 Upload the compressed file to VU-LMS under the designated assignment submission section before the due date.

Rules for Marking: Important Notes:

Please note that your assignment will not be awarded any  This assignment covers Lectures 10 to 22.
marks if:  No assignment will be accepted via email after the due date under
It is submitted after the due date. any circumstances (including issues like load shedding or internet

It is not submitted in the correct (.zip /.rar) format. disconnection).

It does not open, or the file is corrupted.  Students are strongly encouraged to upload their work at least one
day before the deadline to avoid last-minute problems.
It is fully or partially copied from other students, the
 Kindly avoid posting queries on MDB regarding this assignment.
internet, or course handouts.
➤ If you have any concerns or questions, please email at:
➤ Strict disciplinary action will be taken in such cases.
[email protected].

Objectives of the Assignment:

● To set up and structure a Java project using an IDE. ● To design and implement a user-friendly GUI using Swing.
● To connect the application to a database using JDBC. ● To perform CRUD operations on sales data stored in a database.
● To simulate a real-world business software solution. ● To build, package, and compress the final application correctly.

Good Luck

1
Assignment No. 02
Total Marks: 20
Semester: Spring 2025
Due Date: June 23, 2025
CS506 – Web Design and Development

Problem Statement:
This assignment is a continuation of assignment # 1. Where, you have developed a basic Java program to
predict ice cream sales based on temperature. Although the basic functionality remains the same (i.e., taking
temperature and sales as input from the user, training model and predicting the sales etc.). However, in this
assignment, you are required to store/fetch data to/from a backend database (i.e., MS Access) and display it
in a table using Java Swing based GUI (i.e., Graphical User Interface) components.

Requirements:
1. Graphical User Interface (GUI)
The application must present a GUI that includes appropriate labels, text fields, buttons, and a data
table, as shown in Figure # 1.

2. Add Data Point


Users can add a new data point by entering Temperature and Sales into the respective fields and
clicking the "Add Data Point" button.
 Valid input conditions:
o Both fields are non-empty.
o Temperature: 1–50°C
o Sales: 1–500 units
o The same does not already exist in the database.
 On valid input: Save data to the backend database.
 On invalid input: Show an error prompt/message.

3. Load Data
Clicking the "Load Data" button will fetch and display all data records from the backend database in
ascending order by temperature, shown in a table as in Figure # 2.

4. Delete All Data


Clicking the "Delete All" button should prompt the user for confirmation (see Figure # 3).
 If confirmed: All records are permanently deleted from both the table and the database.

5. Train Model

2
Assignment No. 02
Total Marks: 20
Semester: Spring 2025
Due Date: June 23, 2025
CS506 – Web Design and Development

The "Train Model" button will calculate the slope (m) and intercept (b) using the slope and intercept
formulas provided in Assignment # 1.
o Slope (m) = (n × Σ(xy) − Σx × Σy) / (n × Σ(x²) − (Σx)²)
o Intercept (b) = (Σy − m × Σx) / n
Precondition: At least two data points must exist in the database and be loaded in the table.

6. Predict Sale
To predict sales, it is required to enter a temperature value and click the "Predict Sale" button.
 Input must be non-empty and in the valid range (1 – 50°C).
 Model must be trained beforehand.
 On valid input:
o Calculate the predicted sale:
Predicted Sales = slope x Temperature + intercept
o Display a message showing the predicted sale, the slope (m), and intercept (b) (see
Figure # 4).
o Ask the user if they wish to save the predicted value to the database.
 On invalid input: Show an error prompt/message.

7. ⏻ Exit with Developer Info


When the user clicks the window's close (X) icon, the program should:
 Display a message dialog box with Developer Info (e.g., Student ID and Name) as shown in
Figure # 5.
 Terminate the application afterward.

Sample Output:

Fig. 1: A typical GUI for Sales Prediction Fig. 2: Displaying Data in Table

3
Assignment No. 02
Total Marks: 20
Semester: Spring 2025
Due Date: June 23, 2025
CS506 – Web Design and Development

Fig. 3: Confirming before Delete Fig. 4: Displaying Predicted Value

Fig. 5: Displaying Developer Info

Required Java Code and DB:


Java Classes:
1. DataPoint.java (id, temperature, sale)
2. DbHelper.java (should contain all database related code)
3. MainClass.java (should contain GUI code)

Database file:
4. BSxxxxxxxx.accdb (must be same as your own VU student id)

Note: Need to put database file in assets folder in NetBeans/IntelliJ Idea project directory, as shown below.

4
Assignment No. 02
Total Marks: 20
Semester: Spring 2025
Due Date: June 23, 2025
CS506 – Web Design and Development

Fig. 6: Folder "assets" in the Project Directory

JDK Installation, Setup Files & Video Tutorials:


 Step 1: Download the JDK
 Go to the official Oracle JDK website:

https://www.oracle.com/java/technologies/downloads/
 Choose the latest Java SE Development Kit (e.g., JDK 24).
 Click on the Windows Installer (e.g., .exe file) and download it.
 Step 2: Install the JDK
 Run the downloaded .exe file.

 Follow the installation prompts. You can keep the default settings.
 Finish the installation.
 Step 3: Verify Installation
 Open Command Prompt (cmd).

 Type the following and press Enter:


java -version
 You should see something like:
java version "24.0.1" (or whatever version you installed)

 For complete installation, a video tutorial is also available at VU-LMS.


https://vulms.vu.edu.pk/Courses/CS506/Downloads/JDK_Installation.mp4

 To install & create a HelloWorld Java program in NetBeans IDE, please watch.
https://vulms.vu.edu.pk/Courses/CS506/Downloads/NetBeansIDE_Installation.mp4

 To use UCanAccess driver to connect with MS Access database, please watch.

5
Assignment No. 02
Total Marks: 20
Semester: Spring 2025
Due Date: June 23, 2025
CS506 – Web Design and Development

https://vulms.vu.edu.pk/Courses/CS506/Downloads/UCanAccess_Driver_Installation.mp4

Important Things to Implement:


1. GUI Components (AWT & Swing)
The graphical interface must be built using relevant components from AWT and Swing, such as:
 JFrame, JPanel, JButton, JLabel, JTextField, JTable, etc.

2. Database Connectivity with UCanAccess


You must use the UCanAccess JDBC driver to connect your Java application with an MS Access
database.
 Refer to the provided video tutorial for guidance on configuring UCanAccess.

3. SQL Queries for Data Operations


Use proper SQL statements to perform the following operations with the database:
 Inserting new records
 Fetching data
 Deleting records

4. Object-Oriented Data Handling


Data must be transferred between the program and database in the form of Java objects.
 Use a DataPoint class (provided in Assignment #1 or a modified version) to encapsulate each
record.

5. Java Class Structure


Java classes must be well-structured, including:
 Private data members
 Constructors
 Standard setters/getters
 Member functions to handle logic and operations

6. Exception Handling
Ensure proper exception management throughout the application.
 Common exceptions to handle include:

6
Assignment No. 02
Total Marks: 20
Semester: Spring 2025
Due Date: June 23, 2025
CS506 – Web Design and Development

o NullPointerException
o NumberFormatException
o ClassNotFoundException
o SQLException
 Use try-catch blocks and meaningful messages to handle these scenarios gracefully.

7. Custom Implementation
All images, sample output, and data formats shown in the assignment or documentation are for
reference only.
 You are encouraged to create your own design and functionality, as long as it meets the stated
requirements.

Good Luck

You might also like