Spring 2025 - CS506 - 2
Spring 2025 - CS506 - 2
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
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 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].
● 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.
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.
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.
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
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
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).
To install & create a HelloWorld Java program in NetBeans IDE, please watch.
https://vulms.vu.edu.pk/Courses/CS506/Downloads/NetBeansIDE_Installation.mp4
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
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