FinalReport CSC305 CarRentalSystem
FinalReport CSC305 CarRentalSystem
PROJECT
FINAL REPORT
Submission Date:
7/5/2023 [Car Rental System]
PREPARED BY:
(1) [NURUL NAJIHAH BINTI MUNIR] (2021211212)
(2) [NURUL ZAWANAH BINTI HAMZAH] (2021883062)
(3) [AINATUL NUR NAJIHAH BINTI NORAZIZAN] (2021879862)
(4) [AINUN SOFEA BINTI JAMALUDDIN] (2021491216)
GROUP: KCS110
CSC305 - Programming Paradigms
Diploma in Computer Science, UiTM Kedah, Malaysia
LECTURER:
PUAN NOR HAFIZAH BINTI ABDUL RAZAK
Faculty of Computer & Mathematical Sciences
FINAL REPORT
TABLE OF CONTENT
Topics Page
i) Table of Content 1
ii) The Project 2
a. Project Background 2
b. Problem Statement 2
c. Objectives 2
iii) Suggested solutions.
a. C
i. Array 3
ii. List of Functions 3
iii. Source codes 4 – 19
iv. Sample Input/ Output 20 – 23
b. Java
i. Class diagram 24
ii. Source Code 25 - 28
iii. Sample Input/ Output 29 – 32
iv) Conclusion 33
Page 1
FINAL REPORT
a. Project Background
The car rental system was developed to record and secure the customer's rental car information.
It was created for our customers to use when renting a car from our company. This system
provides the customer with information about our Car Rental Company's system, such as its
capability that all operations can be completed here, including perusing all our company's cars,
reserving the car, the day the customer wishes to rent, and the number of days the customer
wishes to rent. This system provides a registration procedure for reserving a car.
b. Problem Statements
There have always been problems with the car rental system, such as unclear payments that do
not include taxation and the exact day, whether it is a weekend or weekday. As a result, the
user will be misled regarding the total amount of payment required.
c. Objectives
To enable effective management of customer data, including profiles, rental history, and
preferences.
calculate the total price for the customer to pay by using the system.
To compute the total fees if the customer chooses to rent a car during the weekend.
To generate a bill once the customer completed the payment.
Page 2
FINAL REPORT
a. C
i. Array
Car model
The price of rent is based on days and types of cars
Display of available vehicles: This feature shows a list of vehicles that can be rented,
together with information about each vehicle including its model, cost, and availability.
Reserve a car: The consumer can use this feature to choose the preferred vehicle and
specify the rental duration.
Calculate Payment: Using the rental duration, this function computes the total payment,
which includes any taxes or other fees.
Page 3
FINAL REPORT
#include <stdio.h>
#include <string.h>
void getWeekWE(float
price[], int carCount);
void getWeekWD(float
price[], int carCount);
void
displayCarOptions();
void getInputA(float
price[], int carCount);
void getInputB(float
price[], int carCount);
void getInputC(float
price[], int carCount);
void getInputD(float
price[], int carCount);
void printReceipt(char
*name, char models[],
float prices[], int
durations[], float
subtotal[], int
carCount);
float totalAll(float
Page 4
FINAL REPORT
subtotal[], int
carCount);
int main()
char name[100],
week[10],
loginPassword[100];
float prices[10];
char models[10];
int durations[10];
float subtotal[10];
float totalInvoice = 0;
int carCount = 0;
printf("Enter
password: ");
scanf("%s",
loginPassword);
if
(strcmp(loginPassword
, "pass") != 0)
printf("Invalid
login attempt. The
program will now
terminate.\n");
return 0;
Page 5
FINAL REPORT
printf("Welcome to
our car rental system.
Hope you enjoy our
service.\n");
printf("\n----------------
------------------------------
----------------------------
\n");
printf("Please enter
your name: ");
scanf("%s", name);
do
printf("\nEnter the
day you want to start
renting the car (written
in uppercase letters):
");
scanf("%s",
week);
Page 6
FINAL REPORT
if (strcmp(week,
"SUNDAY") == 0 ||
strcmp(week,
"SATURDAY") == 0)
getWeekWE(prices,
carCount);
else
getWeekWD(prices,
carCount);
displayCarOptions();
scanf(" %c",
&models[carCount]);
switch
(models[carCount])
case 'A':
getInputA(prices,
carCount);
break;
Page 7
FINAL REPORT
case 'B':
getInputB(prices,
carCount);
break;
case 'C':
getInputC(prices,
carCount);
break;
case 'D':
getInputD(prices,
carCount);
break;
default:
printf("Invalid
car model selected.
Please try again.\n");
continue;
printf("How many
days do you want to
rent: ");
scanf("%d",
&durations[carCount]);
subtotal[carCount] =
Page 8
FINAL REPORT
calcPrice(durations[car
Count],
prices[carCount]);
totalInvoice +=
subtotal[carCount];
carCount++;
printf("---------------
------------------------------
-----------------------------
\n");
printf("\nDo you
want to add another
car rental? (Y-Yes, N-
No): ");
scanf(" %c",
&ans);
printReceipt(name,
models, prices,
durations, subtotal,
carCount);
printf("\nTotal Rental
Amount for %d cars is:
RM %.1f\n", carCount,
totalInvoice);
// Ask if the
customer wants to
Page 9
FINAL REPORT
char deleteChoice;
scanf(" %c",
&deleteChoice);
if (deleteChoice ==
'Y' || deleteChoice ==
'y')
char deleteModel;
printf("Enter the
car model to be
deleted (A, B, C, or D):
");
scanf(" %c",
&deleteModel);
int deleteIndex = -
1;
Page 10
FINAL REPORT
if (models[i] ==
deleteModel)
deleteIndex
= i;
break;
if (deleteIndex != -
1)
// Remove the
car rental from the
arrays
for (int i =
deleteIndex; i <
carCount - 1; i++)
prices[i] =
prices[i + 1];
models[i] =
models[i + 1];
durations[i] =
durations[i + 1];
subtotal[i] =
subtotal[i + 1];
Page 11
FINAL REPORT
carCount--;
// Recalculate
the total invoice
amount
totalInvoice =
totalAll(subtotal,
carCount);
printf("\nCar
rental deleted
successfully.\n");
// Print the
updated invoice
printReceipt(name,
models, prices,
durations, subtotal,
carCount);
printf("\nTotal
Rental Amount for %d
cars is: RM %.1f\n",
carCount, totalInvoice);
else
printf("\nCar
model not found in the
invoice. No changes
made.\n");
Page 12
FINAL REPORT
return 0;
void getWeekWE(float
price[], int carCount)
price[carCount] =
50.0f;
printf("\nYour
additional fee is RM
%.1f\n",
price[carCount]);
void getWeekWD(float
price[], int carCount)
price[carCount] =
0.0f;
printf("\nYour
additional fee is RM
%.1f\n",
price[carCount]);
void
displayCarOptions()
Page 13
FINAL REPORT
printf("\n----------------
------------------------------
----------------------------");
printf("\n-----Please
Select a Car-----");
printf("Please enter
the right car model and
choose from the above
options: ");
void getInputA(float
price[], int carCount)
printf("\nYou have
chosen:--------------------
------------|HONDA
CIVIC\n");
printf("Car colour:----
------------------------------
---|RED\n");
Page 14
FINAL REPORT
printf("Number
plate:-----------------------
------------|KCE
1298\n");
price[carCount] =
150.0f;
printf("Rent per
day:-------------------------
----------|RM %.2f\n",
price[carCount]);
void getInputB(float
price[], int carCount)
printf("You have
chosen:--------------------
------------|BMW\n");
printf("Car colour:----
------------------------------
---|BLUE\n");
printf("Number
plate:-----------------------
------------|SYG
4598\n");
price[carCount] =
200.0f;
printf("Rent per
day:-------------------------
----------|RM %.2f\n",
price[carCount]);
Page 15
FINAL REPORT
void getInputC(float
price[], int carCount)
printf("You have
chosen:--------------------
------------|MYVI\n");
printf("Car colour:----
------------------------------
---|GREEN\n");
printf("Number
plate:-----------------------
------------|CBE
7865\n");
price[carCount] =
100.0f;
printf("Rent per
day:-------------------------
----------|RM %.2f\n",
price[carCount]);
void getInputD(float
price[], int carCount)
printf("You have
chosen:--------------------
------------|TESLA\n");
printf("Car colour:----
Page 16
FINAL REPORT
------------------------------
---|SILVER\n");
printf("Number
plate:-----------------------
------------|KCK
5948\n");
price[carCount] =
250.0f;
printf("Rent per
day:-------------------------
----------|RM %.2f\n",
price[carCount]);
void printReceipt(char
*name, char models[],
float prices[], int
durations[], float
subtotal[], int
carCount)
printf("------------------
------------------------------
--------------------------
\n");
Page 17
FINAL REPORT
printf("\n///////////////////////
////////////////////////////////////\
n");
printf("\t Car
Rental - Customer
Invoice\n");
printf("//////////////////////////
/////////////////////////////////\n
");
printf("Customer
Name:----------------------
-------------|%s\n",
name);
printf("Car
Model:---------------------
-----------------|%c\n",
models[i]);
printf("Number of
Days:-----------------------
----------|%d\n",
durations[i]);
printf("Price per
Day:------------------------
----------|RM %.2f\n",
prices[i]);
Page 18
FINAL REPORT
printf("Subtotal:---
------------------------------
------|RM %.2f\n",
subtotal[i]);
printf("\n");
float totalAll(float
subtotal[], int
carCount)
float total = 0;
total +=
subtotal[i];
return total;
Page 19
FINAL REPORT
First and foremost, in order to access the application, the user must enter the password so that the system
may begin to run. If the user enters the correct password, the system will display the message shown below.
If the user enters the incorrect password, the system will display an error message and exit the system.
Page 20
FINAL REPORT
Following that, the system will request the user's name and a start day for renting the car. Then, based on
the user input, our system will determine whether the user needs to pay the additional payment or not.
Next, we include a selection control, which is a 'Linear Selection Structure' that prompts customers to select
the sort of car that will be rented. The system will display a list of automobiles that can be rented, and the
user must enter the alphabet specified by the system, such as 'A' for Honda Civic, 'B' for BMW, 'C' for Myvi,
and 'D' for Tesla.
Page 21
FINAL REPORT
After customers have selected a car, the system will print out information about the car they have selected.
Following that, the user must enter the total number of days that the user wishes to rent the car.
After clients enter the number of days they wish to rent a car for, the system will question whether they wish to
add another vehicle. whether they respond "Y" the system will then ask the customer for the type of vehicle they
wish to rent, as well as the number of days they wish to rent it for.
Page 22
FINAL REPORT
Next, if the consumer types "N" and decides they do not want to add another car, the system will
produce an invoice for the vehicle they rented; but, if they later decide they do want to delete it, they
have to enter "Y".
The system will then ask the customer what automobile model they wish to delete once they select "Y"
as the last option, and if the deletion is successful, a new invoice will be generated for the customer.
Page 23
FINAL REPORT
b. Java
i. Class diagram
Page 24
FINAL REPORT
import java.util.Scanner;
if (!loginPassword.equals("pass")) {
System.out.println("Invalid login attempt. The program will now terminate.");
return;
}
System.out.println("Welcome to our car rental system. Hope you enjoy our service.\n");
System.out.println("--------------------------------------------------------------------------");
System.out.println("Thank you for choosing our car rental system program. Hope you have a nice day
:)");
System.out.print("Please enter your name: ");
name = scanner.next();
do {
System.out.print("\nEnter the day you want to start renting the car (written in uppercase letters): ");
week = scanner.next();
if (week.equals("SUNDAY") || week.equals("SATURDAY")) {
getWeekWE(prices, carCount);
} else {
getWeekWD(prices, carCount);
}
displayCarOptions();
models[carCount] = scanner.next().charAt(0);
switch (models[carCount]) {
case 'A':
getInputA(prices, carCount);
break;
case 'B':
getInputB(prices, carCount);
break;
Page 25
FINAL REPORT
case 'C':
getInputC(prices, carCount);
break;
case 'D':
getInputD(prices, carCount);
break;
default:
System.out.println("Invalid car model selected. Please try again.");
continue;
}
System.out.println("--------------------------------------------------------------------------");
System.out.print("\nDo you want to add another car rental? (Y-Yes, N-No): ");
ans = scanner.next().charAt(0);
} while (ans == 'Y' || ans == 'y');
if (deleteIndex != -1) {
// Remove the car rental from the arrays
for (int i = deleteIndex; i < carCount - 1; i++) {
prices[i] = prices[i + 1];
models[i] = models[i + 1];
durations[i] = durations[i + 1];
subtotal[i] = subtotal[i + 1];
}
carCount--;
Page 26
FINAL REPORT
scanner.close();
}
public static void printReceipt(String name, char[] models, float[] prices, int[] durations, float[] subtotal, int
carCount) {
System.out.println("--------------------------------------------------------------------------");
System.out.println("\n///////////////////////////////////////////////////////////");
System.out.println("\t Car Rental - Customer Invoice");
System.out.println("///////////////////////////////////////////////////////////");
System.out.printf("Customer Name:-----------------------------------|%s\n", name);
Page 28
FINAL REPORT
First and foremost, in order to access the application, the user must enter the password so that the system
may begin to run. If the user enters the correct password, the system will display the message shown below.
If the user enters the incorrect password, the system will display an error message and exit the system.
Page 29
FINAL REPORT
Following that, the system will request the user's name and a start day for renting the car. Then, based on
the user input, our system will determine whether the user needs to pay the additional payment or not.
Next, we include a selection control, which is a 'Linear Selection Structure' that prompts customers to select
the sort of car that will be rented. The system will display a list of automobiles that can be rented, and the
user must enter the alphabet specified by the system, such as 'A' for Honda Civic, 'B' for BMW, 'C' for Myvi,
and 'D' for Tesla.
Page 30
FINAL REPORT
After customers have selected a car, the system will print out information about the car they have selected.
Following that, the user must enter the total number of days that the user wishes to rent the car.
After clients enter the number of days they wish to rent a car for, the system will question whether they wish to
add another vehicle. whether they respond "Y" the system will then ask the customer for the type of vehicle they
wish to rent, as well as the number of days they wish to rent it for.
Page 31
FINAL REPORT
Next, if the consumer types "N" and decides they do not want to add another car, the system will
produce an invoice for the vehicle they rented; but, if they later decide they do want to delete it, they
have to enter "Y".
The system will then ask the customer what automobile model they wish to delete once they select "Y"
as the last option, and if the deletion is successful, a new invoice will be generated for the customer.
Page 32
FINAL REPORT
iv. Conclusion
In conclusion, the car rental system, which was expertly programmed using C and Java,
provides a user-friendly interface that enables customers to select their desired vehicle type and
rental duration with ease. The system of C and Java optimizes performance and memory
management for a seamless user experience by facilitating efficient data management. The GUI
capabilities of Java enhance the system's visual attraction and interactivity, facilitating user
navigation. In addition, the system's ability to add and remove vehicles assures flexibility in fleet
management, making it a dependable and adaptable solution for streamlined car rental
operations. With the successful integration of C and Java, this system exemplifies a robust and
comprehensive tool that provides users and rental providers with convenience and satisfaction.
Page 33