0% found this document useful (0 votes)
43 views31 pages

JDBC Practice Questions

The document outlines the development of various Java applications using JDBC and MySQL for managing different systems including a project tracker for a freelance marketplace, a workshop management system, a book subscription service, and a library book maintenance system. Each system requires CRUD operations, specific table structures, and exception handling for SQL operations. The document provides detailed input/output formats and examples for each application, emphasizing the need for robust data management as the respective services grow.

Uploaded by

pepesheet
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)
43 views31 pages

JDBC Practice Questions

The document outlines the development of various Java applications using JDBC and MySQL for managing different systems including a project tracker for a freelance marketplace, a workshop management system, a book subscription service, and a library book maintenance system. Each system requires CRUD operations, specific table structures, and exception handling for SQL operations. The document provides detailed input/output formats and examples for each application, emphasizing the need for robust data management as the respective services grow.

Uploaded by

pepesheet
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/ 31

QUESTION 1:

Project Tracker System for a Growing Freelance Marketplace

Jake is a software developer working for a rapidly expanding online freelancing


marketplace called "Freelance Workstream." As the platform grows, there is a need for a
system that manages freelance projects, tracks client interactions, monitors the
progress of each project, and ensures timely payments. The management has tasked
Jake with building a database system to store and manage crucial project information.

The database should enable the team to:

1. Add new project details as more freelancers and clients are onboarded.

2. Update the payment status when a project hits a milestone or gets completed.

3. Remove a project record when it is canceled or becomes irrelevant.

4. Retrieve all project details for tracking the project's status and maintaining client
relationships.

Jake has been tasked to create a Java application using JDBC and MySQL to implement
this system. The application must support CRUD (Create, Read, Update, Delete)
operations and handle SQLExceptions efficiently to ensure robust performance.

Table Name: freelance_projects

Table Structure:

• projectId: INT (Primary Key)

• clientName: VARCHAR(50) (Not NULL)

• projectTitle: VARCHAR(100) (Not NULL)

• projectStatus: VARCHAR(20) (e.g., "Ongoing", "Finished", "Pending")

• payment: INT

Additional Requirements:

• Use try/catch and finally blocks to handle SQLExceptions.

• The table name is case-sensitive and must match exactly.

• The projectId values range between 2001 and 2005.

Input Format:

Insert Operation:

Input consists of an operation number (1), followed by the attributes for a new project:
• projectId (INT)

• clientName (VARCHAR)

• projectTitle (VARCHAR)

• projectStatus (VARCHAR)

• payment (INT)

Update Operation:

Input consists of an operation number (2) followed by:

• projectId (INT)

• newPayment (INT)

Delete Operation:

Input consists of an operation number (3) followed by:

• projectId (INT)

View All Details Operation:

Input consists of an operation number (4), with no additional input required.

Output Format:

Insert Operation:

Outputs the message "Project added successfully." followed by the list of all projects
sorted by payment in descending order.

Update Operation:

Outputs the message "Payment updated successfully." followed by the list of all
projects sorted by payment in descending order.

Delete Operation:

Outputs the message "Project deleted successfully." followed by the list of all projects
sorted by payment in descending order.

View All Details Operation:

Displays the list of all projects, sorted by payment in descending order.

Sample 1 Input:

2006
Sarah Johnson

Website Design

Ongoing

2500

Sample 1 Output:

Project added successfully.

Project ID: 2006, Client: Sarah Johnson, Project: Website Design, Status: Ongoing,
Payment: 2500

Project ID: 2002, Client: Mike Lee, Project: Mobile App, Status: Finished, Payment: 1800

Project ID: 2005, Client: Kate Reed, Project: Marketing Campaign, Status: Finished,
Payment: 1300

Project ID: 2004, Client: Alex Kim, Project: Social Media Strategy, Status: Ongoing,
Payment: 900

Project ID: 2001, Client: Emily White, Project: Logo Design, Status: Ongoing, Payment:
600

Project ID: 2003, Client: Tom Green, Project: SEO Plan, Status: Pending, Payment: 400

Sample 2 Input:

2001

800

Sample 2 Output:

Payment updated successfully.

Project ID: 2002, Client: Mike Lee, Project: Mobile App, Status: Finished, Payment: 1800

Project ID: 2005, Client: Kate Reed, Project: Marketing Campaign, Status: Finished,
Payment: 1300

Project ID: 2001, Client: Emily White, Project: Logo Design, Status: Ongoing, Payment:
800

Project ID: 2004, Client: Alex Kim, Project: Social Media Strategy, Status: Ongoing,
Payment: 900

Project ID: 2003, Client: Tom Green, Project: SEO Plan, Status: Pending, Payment: 400
Sample 3 Input:

2001

Sample 3 Output:

Project deleted successfully.

Project ID: 2002, Client: Mike Lee, Project: Mobile App, Status: Finished, Payment: 1800

Project ID: 2005, Client: Kate Reed, Project: Marketing Campaign, Status: Finished,
Payment: 1300

Project ID: 2004, Client: Alex Kim, Project: Social Media Strategy, Status: Ongoing,
Payment: 900

Project ID: 2003, Client: Tom Green, Project: SEO Plan, Status: Pending, Payment: 400

Sample 4 Input:

Sample 4 Output:

Project ID: 2002, Client: Mike Lee, Project: Mobile App, Status: Finished, Payment: 1800

Project ID: 2005, Client: Kate Reed, Project: Marketing Campaign, Status: Finished,
Payment: 1300

Project ID: 2004, Client: Alex Kim, Project: Social Media Strategy, Status: Ongoing,
Payment: 900

Project ID: 2001, Client: Emily White, Project: Logo Design, Status: Ongoing, Payment:
600

Project ID: 2003, Client: Tom Green, Project: SEO Plan, Status: Pending, Payment: 400

QUESTION 2:

Lifelong Learning Workshop Management System

You are tasked with developing a Java application to manage workshops at a Lifelong
Learning Center. The application will track workshop details, instructors, participants,
and their progress status using JDBC and MySQL. The system must support CRUD
(Create, Read, Update, Delete) operations and display the workshops properly.

Table Name: learning_workshops


Table Structure:

• workshopId: INT (Primary Key)

• workshopTitle: VARCHAR(100)

• leadInstructor: VARCHAR(100)

• numParticipants: INT

• progressStatus: VARCHAR(20) (Values can be: 'Planned', 'In Progress', or


'Completed')

Operations:

1. Insert Workshop: Add a new workshop, including workshopId, workshopTitle,


leadInstructor, numParticipants, and progressStatus.

2. Update Workshop: Update the leadInstructor and numParticipants for a


workshop based on its workshopId.

3. Delete Workshop: Remove a workshop using its workshopId.

4. Display All Workshops: List all workshops sorted by workshopId in ascending


order.

NOTES:

• SQLExceptions should be handled using try/catch and finally blocks.

• Ensure the table name matches exactly.

• The workshopId range for the existing records is between 3001 and 3005.

Input Format:

The input consists of an operation number, followed by the required details for each
operation:

1. Insert Operation (1): Input includes workshopId, workshopTitle, leadInstructor,


numParticipants, and progressStatus.

2. Update Operation (2): Input includes workshopId, leadInstructor, and


numParticipants.

3. Delete Operation (3): Input includes workshopId.

4. Display All Workshops (4): No additional input is needed.

Output Format:
1. Insert Operation: Display "Workshop successfully added." followed by the
updated list of workshops in ascending order by workshopId.

2. Update Operation: Display "Workshop successfully updated." followed by the


updated list of workshops in ascending order by workshopId.

3. Delete Operation: Display "Workshop successfully deleted." followed by the


updated list of workshops in ascending order by workshopId.

4. Display All Workshops: List all workshops sorted by workshopId.

Sample Input/Output 1:

Input:

3006

Creative Writing

Sophia Hill

15

In Progress

Output:

Workshop successfully added.

Workshop ID: 3001, Title: Technology for Seniors, Instructor: Lisa Brown, Participants:
20, Status: Completed

Workshop ID: 3002, Title: Wellness & Fitness, Instructor: James Parker, Participants: 10,
Status: In Progress

Workshop ID: 3003, Title: Pottery Class, Instructor: Olivia White, Participants: 12,
Status: Planned

Workshop ID: 3004, Title: Photography Basics, Instructor: Emily Green, Participants: 18,
Status: Completed

Workshop ID: 3005, Title: Gardening 101, Instructor: Robert Clark, Participants: 8,
Status: Planned

Workshop ID: 3006, Title: Creative Writing, Instructor: Sophia Hill, Participants: 15,
Status: In Progress

Sample Input/Output 2:
Input:

3003

Anna Williams

16

Output:

Workshop successfully updated.

Workshop ID: 3001, Title: Technology for Seniors, Instructor: Lisa Brown, Participants:
20, Status: Completed

Workshop ID: 3002, Title: Wellness & Fitness, Instructor: James Parker, Participants: 10,
Status: In Progress

Workshop ID: 3003, Title: Pottery Class, Instructor: Anna Williams, Participants: 16,
Status: Planned

Workshop ID: 3004, Title: Photography Basics, Instructor: Emily Green, Participants: 18,
Status: Completed

Workshop ID: 3005, Title: Gardening 101, Instructor: Robert Clark, Participants: 8,
Status: Planned

QUESTION 3

Book Subscription Management System

Alex is a software developer for a book subscription service called "Reader's Paradise."
The service offers subscription-based book deliveries, where customers receive their
favorite genre or specific book title every month. The management team needs a system
to track these subscriptions and manage key operations like delivery status, monthly
payments, and customer feedback in the form of ratings.

Alex is tasked with developing a Java application using JDBC and MySQL to manage the
book subscriptions and associated tasks.

Table Name: book_subscriptions

Table Structure:

• subscriptionId: INT PRIMARY KEY,

• bookTitle: VARCHAR(100) NOT NULL,


• deliveryStatus: VARCHAR(20) NOT NULL,

• monthlyPayment: INT NOT NULL,

• rating: INT NOT NULL

Operations:

1. Insert a New Subscription:

o Input all fields: subscriptionId, bookTitle, deliveryStatus,


monthlyPayment, and rating for new subscriptions.

o After inserting, the system will display all existing subscriptions sorted by
subscriptionId in ascending order.

2. Update Delivery Status and Payment:

o Based on a subscriptionId, update both the deliveryStatus and


monthlyPayment.

o After updating, the system will display all existing subscriptions sorted by
subscriptionId in ascending order.

3. Delete a Subscription Based on Rating:

o The system will delete a subscription if the provided rating matches any
existing subscription.

o After deleting, the system will display all remaining subscriptions sorted
by subscriptionId in ascending order.

4. Display All Subscriptions:

o The system will display details of all subscriptions sorted by


subscriptionId in ascending order.

NOTE:

• Utilize try/catch and finally block to handle the SQLException.

• The table name is case-sensitive and must match the one specified above.

• The table has already been created, and some rows have been inserted.

• Subscription IDs range between 1001 and 1005.

Input Format:

Insert a new subscription:


• The system will ask for:

o subscriptionId (integer)

o bookTitle (string)

o deliveryStatus (string, e.g., "Pending", "Delivered", "Cancelled")

o monthlyPayment (integer)

o rating (integer, must be between 1 and 5)

Update delivery status and payment:

• The system will ask for:

o subscriptionId (integer)

o New deliveryStatus (string, e.g., "Pending", "Delivered", "Cancelled")

o New monthlyPayment (integer)

Delete a subscription based on rating:

• The system will ask for:

o rating (integer between 1 and 5). The system will delete the first
subscription it finds with the given rating.

Display subscriptions:

• No input is required for this operation; it will simply display all subscriptions
sorted by subscriptionId in ascending order.

Output Format:

Insert Operation:

• The system will display: "Subscription added successfully." followed by a list of


all subscriptions sorted by subscriptionId in ascending order.

Update Operation:

• The system will display: "Subscription updated successfully." followed by a list of


all subscriptions sorted by subscriptionId in ascending order.

Delete Operation:

• If a subscription is deleted, the system will display: "Subscription deleted


successfully." followed by a list of all remaining subscriptions sorted by
subscriptionId in ascending order.
Display Subscriptions:

• The system will display all subscriptions sorted by subscriptionId in ascending


order.

Sample Input and Output:

Sample 1 Input:

1006

The Great Gatsby

Pending

50

Sample 1 Output:

Subscription added successfully.

Subscription ID: 1001, Book Title: To Kill a Mockingbird, Delivery Status: Pending,
Monthly Payment: 30, Rating: 4

Subscription ID: 1002, Book Title: 1984, Delivery Status: Delivered, Monthly Payment:
35, Rating: 5

Subscription ID: 1003, Book Title: Moby Dick, Delivery Status: Cancelled, Monthly
Payment: 25, Rating: 3

Subscription ID: 1004, Book Title: Pride and Prejudice, Delivery Status: Pending,
Monthly Payment: 40, Rating: 4

Subscription ID: 1005, Book Title: War and Peace, Delivery Status: Delivered, Monthly
Payment: 50, Rating: 5

Subscription ID: 1006, Book Title: The Great Gatsby, Delivery Status: Pending, Monthly
Payment: 50, Rating: 5

Sample 2 Input:

1002
Cancelled

40

Sample 2 Output:

Subscription updated successfully.

Subscription ID: 1001, Book Title: To Kill a Mockingbird, Delivery Status: Pending,
Monthly Payment: 30, Rating: 4

Subscription ID: 1002, Book Title: 1984, Delivery Status: Cancelled, Monthly Payment:
40, Rating: 5

Subscription ID: 1003, Book Title: Moby Dick, Delivery Status: Cancelled, Monthly
Payment: 25, Rating: 3

Subscription ID: 1004, Book Title: Pride and Prejudice, Delivery Status: Pending,
Monthly Payment: 40, Rating: 4

Subscription ID: 1005, Book Title: War and Peace, Delivery Status: Delivered, Monthly
Payment: 50, Rating: 5

Sample 3 Input:

Sample 3 Output:

Subscription deleted successfully.

Subscription ID: 1001, Book Title: To Kill a Mockingbird, Delivery Status: Pending,
Monthly Payment: 30, Rating: 4

Subscription ID: 1002, Book Title: 1984, Delivery Status: Cancelled, Monthly Payment:
40, Rating: 5

Subscription ID: 1004, Book Title: Pride and Prejudice, Delivery Status: Pending,
Monthly Payment: 40, Rating: 4

Subscription ID: 1005, Book Title: War and Peace, Delivery Status: Delivered, Monthly
Payment: 50, Rating: 5

Sample 4 Input:

Sample 4 Output:
Subscription ID: 1001, Book Title: To Kill a Mockingbird, Delivery Status: Pending,
Monthly Payment: 30, Rating: 4

Subscription ID: 1002, Book Title: 1984, Delivery Status: Cancelled, Monthly Payment:
40, Rating: 5

Subscription ID: 1003, Book Title: Moby Dick, Delivery Status: Cancelled, Monthly
Payment: 25, Rating: 3

Subscription ID: 1004, Book Title: Pride and Prejudice, Delivery Status: Pending,
Monthly Payment: 40, Rating: 4

Subscription ID: 1005, Book Title: War and Peace, Delivery Status: Delivered, Monthly
Payment: 50, Rating: 5

QUESTION 4:

Library Book Maintenance System

In a bustling city, the public library plays a critical role in supporting the education and
leisure of its citizens. To ensure that the books are well-maintained, the library
management has implemented a system for tracking book maintenance tasks. This
system helps monitor tasks assigned to different maintenance staff, categorize them by
priority, and determine the frequency of each task. As the lead developer, your
responsibility is to create a Java application using JDBC and MySQL to manage these
maintenance tasks efficiently.

Table Name: book_maintenance

Table Structure:

• taskId: INT PRIMARY KEY

• bookTitle: VARCHAR(150) NOT NULL

• assignedStaff: VARCHAR(50) NOT NULL

• priorityLevel: VARCHAR(20) NOT NULL // e.g., "Low", "Medium", "High"

• maintenanceInterval: VARCHAR(20) NOT NULL // e.g., "Monthly", "Weekly",


"Quarterly"

Operations:

1. Insert a New Maintenance Task:


Input all fields: taskId, bookTitle, assignedStaff, priorityLevel, and
maintenanceInterval.
After inserting, the system will display all tasks.
2. Update Task Priority and Interval:
Based on taskId, update both the priorityLevel and maintenanceInterval.
After updating, the system will display all tasks.

3. Delete a Task Based on Staff Name:


The system will delete the first task found with the specified assignedStaff.
After deleting, the system will display all tasks.

4. Display All Tasks Sorted by Priority:


Display details of all tasks.

NOTE:

• Utilize try/catch and finally blocks to handle SQLException.

• The table name is case-sensitive and must match the one specified above.

• The table has already been created, and some records have been inserted.

• The taskId range is between 2001 and 2005.

Input Format:

For Insert a New Maintenance Task:

taskId (integer)

bookTitle (string)

assignedStaff (string)

priorityLevel (string, e.g., "Low", "Medium", "High")

maintenanceInterval (string, e.g., "Monthly", "Weekly", "Quarterly")

For Update Task Priority and Interval:

taskId (integer, for the task to update)

New priorityLevel (string, e.g., "Low", "Medium", "High")

New maintenanceInterval (string, e.g., "Monthly", "Weekly", "Quarterly")

For Delete a Task Based on Staff Name:

3
assignedStaff (string)

For Display All Tasks:

Output Format:

• For Insert Operation:


The system will display: "Task added successfully." followed by a list of all tasks.

• For Update Operation:


The system will display: "Task updated successfully." followed by a list of all
tasks.

• For Delete Operation:


If a task is deleted, the system will display: "Task deleted successfully." followed
by a list of all tasks.

• For Display All Tasks:


The system will display all tasks.

Sample Input and Output:

Sample 1 Input:

2006

Moby Dick

Staff B

High

Monthly

Sample 1 Output:

Task added successfully.

Task ID: 2001, Book Title: To Kill a Mockingbird, Assigned Staff: Staff A, Priority: High,
Interval: Weekly

Task ID: 2002, Book Title: 1984, Assigned Staff: Staff C, Priority: Medium, Interval:
Monthly

Task ID: 2003, Book Title: The Catcher in the Rye, Assigned Staff: Staff D, Priority: Low,
Interval: Quarterly
Task ID: 2004, Book Title: The Great Gatsby, Assigned Staff: Staff E, Priority: High,
Interval: Monthly

Task ID: 2005, Book Title: War and Peace, Assigned Staff: Staff F, Priority: Medium,
Interval: Weekly

Task ID: 2006, Book Title: Moby Dick, Assigned Staff: Staff B, Priority: High, Interval:
Monthly

Sample 2 Input:

2003

Medium

Weekly

Sample 2 Output:

Task updated successfully.

Task ID: 2001, Book Title: To Kill a Mockingbird, Assigned Staff: Staff A, Priority: High,
Interval: Weekly

Task ID: 2002, Book Title: 1984, Assigned Staff: Staff C, Priority: Medium, Interval:
Monthly

Task ID: 2003, Book Title: The Catcher in the Rye, Assigned Staff: Staff D, Priority:
Medium, Interval: Weekly

Task ID: 2004, Book Title: The Great Gatsby, Assigned Staff: Staff E, Priority: High,
Interval: Monthly

Task ID: 2005, Book Title: War and Peace, Assigned Staff: Staff F, Priority: Medium,
Interval: Weekly

Sample 3 Input:

Staff A

Sample 3 Output:

Task deleted successfully.

Task ID: 2002, Book Title: 1984, Assigned Staff: Staff C, Priority: Medium, Interval:
Monthly
Task ID: 2003, Book Title: The Catcher in the Rye, Assigned Staff: Staff D, Priority:
Medium, Interval: Weekly

Task ID: 2004, Book Title: The Great Gatsby, Assigned Staff: Staff E, Priority: High,
Interval: Monthly

Task ID: 2005, Book Title: War and Peace, Assigned Staff: Staff F, Priority: Medium,
Interval: Weekly

Sample 4 Input:

Sample 4 Output:

Task ID: 2001, Book Title: To Kill a Mockingbird, Assigned Staff: Staff A, Priority: High,
Interval: Weekly

Task ID: 2002, Book Title: 1984, Assigned Staff: Staff C, Priority: Medium, Interval:
Monthly

Task ID: 2003, Book Title: The Catcher in the Rye, Assigned Staff: Staff D, Priority:
Medium, Interval: Weekly

Task ID: 2004, Book Title: The Great Gatsby, Assigned Staff: Staff E, Priority: High,
Interval: Monthly

Task ID: 2005, Book Title: War and Peace, Assigned Staff: Staff F, Priority: Medium,
Interval: Weekly

QUESTION 5:
Task Management System for Freelance Projects

Freelancing platforms require a reliable task management system to help freelancers


keep track of their ongoing projects and ensure timely delivery. This system allows
freelancers to manage their projects by tracking task details, assigning urgency, and
monitoring completion percentages. Your task is to develop a Java application using
JDBC and MySQL to efficiently manage these freelance tasks.

Table Name: freelance_tasks

Table Structure:

• taskId: INT PRIMARY KEY

• projectName: VARCHAR(100) NOT NULL

• freelancer: VARCHAR(100) NOT NULL


• taskCategory: VARCHAR(30) NOT NULL // e.g., "Design", "Development",
"Marketing"

• completionPercent: INT NOT NULL // Completion percentage (0 to 100)

Operations:

1. Add a New Task:

Input all fields: taskId, projectName, freelancer, taskCategory, and completionPercent.


After adding the task, the system will display all tasks sorted by completionPercent in
ascending order.

2. Update Task Category and Completion:

Based on taskId, update both taskCategory and completionPercent.


After updating, the system will display all tasks sorted by completionPercent in
ascending order.

3. Delete a Task by Freelancer Name:

The system will delete the first task found associated with the specified freelancer.
After deletion, the system will display all remaining tasks sorted by completionPercent
in ascending order.

4. Display All Tasks:

Display details of all tasks sorted by completionPercent in ascending order.

NOTE:

• Use try/catch and finally blocks to handle SQLExceptions.

• The table name is case-sensitive and must match the specified one.

• Assume the table has been created and contains some pre-existing records, with
taskId values ranging between 101 and 105.

Input Format:

For Adding a New Task:

taskId (integer)
projectName (string)

freelancer (string)

taskCategory (string, e.g., "Design", "Development", "Marketing")

completionPercent (integer, e.g., 0 to 100)

For Updating Task Category and Completion:

taskId (integer, for the task to update)

New taskCategory (string, e.g., "Design", "Development", "Marketing")

New completionPercent (integer, e.g., 0 to 100)

For Deleting a Task by Freelancer Name:

freelancer (string)

For Displaying All Tasks:

Output Format:

For Adding a New Task:

Task added successfully.

Task ID: ..., Project Name: ..., Freelancer: ..., Category: ..., Completion: ...%

For Updating a Task:

Task updated successfully.

Task ID: ..., Project Name: ..., Freelancer: ..., Category: ..., Completion: ...%

For Deleting a Task:

Task deleted successfully.

Task ID: ..., Project Name: ..., Freelancer: ..., Category: ..., Completion: ...%

For Displaying All Tasks:

Task ID: ..., Project Name: ..., Freelancer: ..., Category: ..., Completion: ...%

Sample 1 Input:

1
106

Mobile App Design

Jane

Design

45

Sample 1 Output:

Task added successfully.

Task ID: 102, Project Name: Website Redesign, Freelancer: Bob, Category:
Development, Completion: 30%

Task ID: 101, Project Name: Logo Creation, Freelancer: Alice, Category: Design,
Completion: 50%

Task ID: 106, Project Name: Mobile App Design, Freelancer: Jane, Category: Design,
Completion: 45%

Task ID: 105, Project Name: Social Media Strategy, Freelancer: David, Category:
Marketing, Completion: 75%

Sample 2 Input:

101

Development

60

Sample 2 Output:

Task updated successfully.

Task ID: 102, Project Name: Website Redesign, Freelancer: Bob, Category:
Development, Completion: 30%

Task ID: 101, Project Name: Logo Creation, Freelancer: Alice, Category: Development,
Completion: 60%

Task ID: 105, Project Name: Social Media Strategy, Freelancer: David, Category:
Marketing, Completion: 75%

Sample 3 Input:

3
Alice

Sample 3 Output:

Task deleted successfully.

Task ID: 102, Project Name: Website Redesign, Freelancer: Bob, Category:
Development, Completion: 30%

Task ID: 105, Project Name: Social Media Strategy, Freelancer: David, Category:
Marketing, Completion: 75%

Sample 4 Input:

Sample 4 Output:

Task ID: 102, Project Name: Website Redesign, Freelancer: Bob, Category:
Development, Completion: 30%

Task ID: 105, Project Name: Social Media Strategy, Freelancer: David, Category:
Marketing, Completion: 75%

QUESTION 6:
Recipe Management System

In today’s world of culinary innovation, managing a collection of favorite recipes


efficiently is essential for chefs and home cooks alike. A Recipe Management System
has been developed to help users manage their personal recipe collections. This
system enables users to add recipes, categorize them by meal type, and track the
number of times a recipe has been prepared. You are responsible for creating a Java
application using JDBC and MySQL to manage these recipes.

Table Name: recipe_collection

Table Structure:

• recipeId: INT PRIMARY KEY

• recipeTitle: VARCHAR(100) NOT NULL

• chefName: VARCHAR(100) NOT NULL

• mealType: VARCHAR(50) NOT NULL // e.g., "Breakfast", "Lunch", "Dinner",


"Dessert"

• prepCount: INT NOT NULL // Number of times the recipe has been prepared
Operations:

1. Add a New Recipe:

o Input all fields: recipeId, recipeTitle, chefName, mealType, and


prepCount.

o After adding, the system will display all recipes sorted by prepCount in
descending order.

2. Update Recipe Preparation Count:

o Based on recipeId, update the prepCount.

o After updating, the system will display all recipes sorted by prepCount in
descending order.

3. Remove a Recipe by Chef's Name:

o The system will delete the first recipe associated with the specified
chefName.

o After deletion, the system will display all recipes sorted by prepCount in
descending order.

4. Display All Recipes:

o Show details of all recipes sorted by prepCount in descending order.

NOTE:

• Utilize try/catch and finally blocks to handle SQLException.

• The table name is case-sensitive and must match the one specified above.

• The table has been created, and some tuples have already been inserted with
IDs ranging from 1001 to 1005.

Input Format

For Adding a New Recipe:

recipeId (integer)

recipeTitle (string)

chefName (string)

mealType (string, e.g., "Breakfast", "Lunch", "Dinner", "Dessert")


prepCount (integer, e.g., 0 or more)

For Updating Recipe Preparation Count:

recipeId (integer, for the recipe to update)

newPrepCount (integer, e.g., 0 or more)

For Removing a Recipe by Chef's Name:

chefName (string)

For Displaying All Recipes:

Output Format

• For the Add Operation:

The system will display: "Recipe added successfully." followed by a list of all recipes
sorted by prepCount in descending order.

• For the Update Operation:

The system will display: "Preparation count updated successfully." followed by a list of
all recipes sorted by prepCount in descending order.

• For the Removal Operation:

If a recipe is deleted, the system will display: "Recipe deleted successfully." followed by
a list of all remaining recipes sorted by prepCount in descending order.

• For the Display Operation:

The system will display all recipes sorted by prepCount in descending order.

Sample 1 Input:

1006

Pancakes

Emily Johnson

Breakfast

450
Sample 1 Output:

Recipe added successfully.

ID: 1006, Title: Pancakes, Chef: Emily Johnson, Meal Type: Breakfast, Prepared: 450
times

ID: 1003, Title: Sushi Rolls, Chef: Akira Sato, Meal Type: Lunch, Prepared: 300 times

ID: 1001, Title: Spaghetti Bolognese, Chef: Mario Rossi, Meal Type: Dinner, Prepared:
250 times

ID: 1004, Title: Chocolate Mousse, Chef: Sophie Laine, Meal Type: Dessert, Prepared:
200 times

ID: 1005, Title: Caesar Salad, Chef: John Green, Meal Type: Lunch, Prepared: 150 times

ID: 1002, Title: French Toast, Chef: Sarah Lee, Meal Type: Breakfast, Prepared: 100 times

Sample 2 Input:

1001

300

Sample 2 Output:

Preparation count updated successfully.

ID: 1001, Title: Spaghetti Bolognese, Chef: Mario Rossi, Meal Type: Dinner, Prepared:
300 times

ID: 1003, Title: Sushi Rolls, Chef: Akira Sato, Meal Type: Lunch, Prepared: 300 times

ID: 1004, Title: Chocolate Mousse, Chef: Sophie Laine, Meal Type: Dessert, Prepared:
200 times

ID: 1005, Title: Caesar Salad, Chef: John Green, Meal Type: Lunch, Prepared: 150 times

ID: 1002, Title: French Toast, Chef: Sarah Lee, Meal Type: Breakfast, Prepared: 100 times

Sample 3 Input:

Mario Rossi

Sample 3 Output:

Recipe deleted successfully.


ID: 1003, Title: Sushi Rolls, Chef: Akira Sato, Meal Type: Lunch, Prepared: 300 times

ID: 1004, Title: Chocolate Mousse, Chef: Sophie Laine, Meal Type: Dessert, Prepared:
200 times

ID: 1005, Title: Caesar Salad, Chef: John Green, Meal Type: Lunch, Prepared: 150 times

ID: 1002, Title: French Toast, Chef: Sarah Lee, Meal Type: Breakfast, Prepared: 100 times

Sample 4 Input:

Sample 4 Output:

ID: 1003, Title: Sushi Rolls, Chef: Akira Sato, Meal Type: Lunch, Prepared: 300 times

ID: 1001, Title: Spaghetti Bolognese, Chef: Mario Rossi, Meal Type: Dinner, Prepared:
250 times

ID: 1004, Title: Chocolate Mousse, Chef: Sophie Laine, Meal Type: Dessert, Prepared:
200 times

ID: 1005, Title: Caesar Salad, Chef: John Green, Meal Type: Lunch, Prepared: 150 times

ID: 1002, Title: French Toast, Chef: Sarah Lee, Meal Type: Breakfast, Prepared: 100 times

QUESTION 7:

Autonomous Vehicle Fleet Management System

As technology advances, autonomous vehicles (self-driving cars) have become


essential for transportation services. To ensure efficient fleet management, an
Autonomous Vehicle Fleet Management System has been developed to monitor each
vehicle's model, passenger capacity, battery status, and maintenance schedule. Your
task is to create a Java application using JDBC and MySQL to manage this fleet
effectively.

Table Name: vehicles

Table Structure:

• vehicleId: INT PRIMARY KEY — Unique identifier for each vehicle.

• vehicleModel: VARCHAR(50) NOT NULL — Model of the autonomous vehicle.


• passengerCapacity: INT NOT NULL — Maximum number of passengers the
vehicle can accommodate.

• batteryStatus: INT NOT NULL — Battery status percentage of the vehicle (0 to


100).

• maintenanceSchedule: INT NOT NULL — Number of trips the vehicle can make
before needing maintenance.

Operations:

1. Add a New Vehicle:

Input all fields: vehicleId, vehicleModel, passengerCapacity, batteryStatus, and


maintenanceSchedule.
After adding, the system will display all vehicles sorted by batteryStatus in descending
order.

2. Update Vehicle Details:

Based on vehicleId, update the following vehicle details: vehicleModel,


passengerCapacity, batteryStatus, and maintenanceSchedule.
After updating, the system will display all vehicles sorted by batteryStatus in
descending order.

3. Remove a Vehicle by Battery Percentage:

The system will delete the first vehicle that has the specified batteryStatus percentage.
After deletion, the system will display all remaining vehicles sorted by batteryStatus in
descending order.

4. Display All Vehicles:

Show details of all vehicles, sorted by batteryStatus in descending order.

NOTE:

• Utilize try/catch and finally blocks to handle the SQLException.

• The table name is case-sensitive and must match the one specified above.
• The table is created, and some records have already been inserted into the table.

• vehicleId range is between 1001 to 1005.

Input Format:

For Adding a New Vehicle:

vehicleId (integer)

vehicleModel (string)

passengerCapacity (integer)

batteryStatus (integer)

maintenanceSchedule (integer)

For Updating Vehicle Details:

vehicleId (integer)

vehicleModel (string)

passengerCapacity (integer)

batteryStatus (integer)

maintenanceSchedule (integer)

For Removing a Vehicle by Battery Percentage:

batteryStatus (integer, e.g., 0 to 100)

For Displaying All Vehicles:

Output Format:

• For Adding Operation: The system will display:


"Vehicle added successfully." followed by a list of all vehicles sorted by
batteryStatus in descending order.
• For Update Operation: The system will display:
"Vehicle updated successfully." followed by a list of all vehicles sorted by
batteryStatus in descending order.

• For Removal Operation: If a vehicle is deleted, the system will display:


"Vehicle deleted successfully." followed by a list of all remaining vehicles sorted
by batteryStatus in descending order.

• For Displaying All Vehicles: The system will display all vehicles sorted by
batteryStatus in descending order.

Sample 1 Input:

1006

Tesla Model X

85

12

Sample 1 Output:

Vehicle added successfully.

ID: 1003, Model: Waymo One, Capacity: 5, Battery Status: 95%, Maintenance Schedule:
15

ID: 1006, Model: Tesla Model X, Capacity: 7, Battery Status: 85%, Maintenance
Schedule: 12

ID: 1001, Model: Cruise Origin, Capacity: 6, Battery Status: 80%, Maintenance
Schedule: 10

ID: 1002, Model: Zoox Shuttle, Capacity: 4, Battery Status: 60%, Maintenance Schedule:
8

ID: 1005, Model: Apollo RT6, Capacity: 10, Battery Status: 55%, Maintenance Schedule:
15

ID: 1004, Model: Nuro R2, Capacity: 2, Battery Status: 40%, Maintenance Schedule: 5

Sample 2 Input:

2
1003

Tesla Model Y

70

10

Sample 2 Output:

Vehicle updated successfully.

ID: 1001, Model: Cruise Origin, Capacity: 6, Battery Status: 80%, Maintenance
Schedule: 10

ID: 1003, Model: Tesla Model Y, Capacity: 6, Battery Status: 70%, Maintenance
Schedule: 10

ID: 1002, Model: Zoox Shuttle, Capacity: 4, Battery Status: 60%, Maintenance Schedule:
8

ID: 1005, Model: Apollo RT6, Capacity: 10, Battery Status: 55%, Maintenance Schedule:
15

ID: 1004, Model: Nuro R2, Capacity: 2, Battery Status: 40%, Maintenance Schedule: 5

Sample 3 Input:

95

Sample 3 Output:

Vehicle deleted successfully.

ID: 1001, Model: Cruise Origin, Capacity: 6, Battery Status: 80%, Maintenance
Schedule: 10

ID: 1002, Model: Zoox Shuttle, Capacity: 4, Battery Status: 60%, Maintenance Schedule:
8

ID: 1005, Model: Apollo RT6, Capacity: 10, Battery Status: 55%, Maintenance Schedule:
15

ID: 1004, Model: Nuro R2, Capacity: 2, Battery Status: 40%, Maintenance Schedule: 5

Sample 4 Input:

4
Sample 4 Output:

ID: 1003, Model: Waymo One, Capacity: 5, Battery Status: 95%, Maintenance Schedule:
15

ID: 1001, Model: Cruise Origin, Capacity: 6, Battery Status: 80%, Maintenance
Schedule: 10

ID: 1002, Model: Zoox Shuttle, Capacity: 4, Battery Status: 60%, Maintenance Schedule:
8

ID: 1005, Model: Apollo RT6, Capacity: 10, Battery Status: 55%, Maintenance Schedule:
15

ID: 1004, Model: Nuro R2, Capacity: 2, Battery Status: 40%, Maintenance Schedule: 5

QUESTION 8:

Patient Health Condition Management System

In the modern healthcare environment, effectively managing patient health condition


data is vital for monitoring and improving public health outcomes. You are tasked with
developing a Java application to manage patient health condition data using JDBC and
MySQL. This application will allow healthcare professionals to perform CRUD (Create,
Read, Update, Delete) operations on health condition data stored in a database,
ensuring easy access to essential information regarding various health issues.

Table Name: health_conditions

Table Structure:

• conditionId: INT (Primary Key)

• conditionName: VARCHAR(50)

• severityLevel: DOUBLE (The range is typically between 0.0 and 10.0)

• symptoms: VARCHAR(100)

• treatment: VARCHAR(100)

Operations:

1. Insert Condition Details: Add a new health condition entry with all details
including conditionId, conditionName, severityLevel, symptoms, and treatment.

2. Update Condition Details: Update the severityLevel and treatment for a


condition based on its conditionId.
3. Delete Condition Details: Remove a health condition entry based on its
conditionId.

4. Show All Condition Details: Display all health condition records sorted by
severityLevel in descending order.

NOTE:

• Utilize try/catch and finally blocks to handle the SQLException.

• The table name is case-sensitive and must match the one specified above.

• The table is created, and some entries have already been inserted into the table.

• ID range is between 1001 to 1005.

Input Format:

The input consists of a number representing the CRUD operations as follows:

• 1 - Insert: All attributes for the new condition (conditionId, conditionName,


severityLevel, symptoms, treatment).

• 2 - Update: The conditionId, new severityLevel, and new treatment.

• 3 - Delete: The conditionId of the condition to be removed.

• 4 - Show All: No additional input is required.

Output Format:

The output should perform the selected CRUD operation based on the input. For each
operation, display appropriate messages and show updated condition details as
follows:

• Insert: Display "Condition added successfully." followed by the updated list of


conditions sorted by 'severityLevel' in descending order.

• Update: Display "Condition updated successfully." followed by the updated list


of conditions sorted by 'conditionName' in alphabetical order.

• Delete: Display "Condition deleted successfully." followed by the updated list of


conditions sorted by 'severityLevel' in descending order.

• Show All: Display all condition records sorted by 'severityLevel' in descending


order.

Sample Input:

1008
Hypertension

7.5

Headaches, Dizziness

Lifestyle changes, Medication

Sample Output:

Condition added successfully.

ID: 1002, Name: Diabetes, Severity Level: 8.0, Symptoms: Increased thirst, Fatigue,
Treatment: Insulin, Lifestyle changes

ID: 1005, Name: Asthma, Severity Level: 6.0, Symptoms: Shortness of breath,
Coughing, Treatment: Inhalers, Avoiding triggers

ID: 1008, Name: Hypertension, Severity Level: 7.5, Symptoms: Headaches, Dizziness,
Treatment: Lifestyle changes, Medication

ID: 1001, Name: Influenza, Severity Level: 4.5, Symptoms: Fever, Cough, Treatment:
Rest, Hydration

ID: 1003, Name: Malaria, Severity Level: 5.0, Symptoms: Fever, Chills, Sweating,
Treatment: Antimalarial medications

ID: 1004, Name: Tuberculosis, Severity Level: 3.0, Symptoms: Cough, Weight Loss,
Treatment: Antibiotics

You might also like