T3_SEM-I_JAVA-I_2023_9-MARKS-PRACTICE PROGRAMS
T3_SEM-I_JAVA-I_2023_9-MARKS-PRACTICE PROGRAMS
TEST-3
1 Write a program using array of objects, which can be used by a banker to open new
accounts.
At the time of opening new account, the banker first enters the number of accounts to be
created. In each account, the information to be stored are- Account number( 10 digits),
Customer name, PAN number(10 digits alphanumeric with capital alphabets) and initial
balance(minimum 5000).
Create a class Account with data members as account number(AN), customer
name(name),account balance(balance) and PAN number(PAN).
Define a method setAccountNumber() that takes account number from the banker and
checks whether it is 10 digits only. If it is less than or greater than 10 digits then it must
print the message ‘Account number must be of ten digits only’ and if any other
keyboard character is entered, it must print the message ‘Account number contains 0
to 9 numbers only’ and prompts to enter the correct account number again.(EX.-
1234567891)
Define a method setName() which takes customer’s first_name, middle_name and last
name.
Define a method setBalance() which takes account balance as input, checks if it is
more
than 5000 and if not, prints the message ‘Initial balance must be more than 5000’ and
prompts to enter balance again.
Define a method setPAN() that accepts and checks whether the first 5 digits are capital
alphabets, next 4 digits are numbers between 0 and 9 and last digit is capital alphabet.
If not, it prints the message ‘The first 5 characters of PAN card are capital alphabets,
followed by 4 numeric digits and ending again with a capital alphabet’ and asks to
enter the PAN card number again.(EX.- ABCDE1234P)
Define a method printData() which prints the details of all accounts i.e. account
number, Customer name, balance and PAN number. The customer name must be
printed in the format- first_name middle_name last name.
Also, the program must contain a code to search an account number and display details
of that
account number. For that create method named searchData() in which Array of account
will
pass as argument(parameters). If an account number is not found, it must print a message
‘This account number does not exist in our bank’.
HINT:-
# INPUT:-
Enter total no of Accounts you want to add: 2
1
L.J Institute of Engineering and Technology, Ahmedabad.
Computer Programming Using JAVA-I Question Bank SEM-I 2023
4
L.J Institute of Engineering and Technology, Ahmedabad.
Computer Programming Using JAVA-I Question Bank SEM-I 2023
Employee Designation:junior
Employee Original Salary:10000.0
Employee Incremented Salary:12000.0
Details of Employee 3
Employee ID:3
Employee Name:vinit
Employee Joinig Year:2010
Employee Experiennce:13
Employee Designation:manager
Employee Original Salary:10000.0
Employee Incremented Salary:11500.0
3 Create a class Student which has Roll_no as int data member, Name as String data
member,
Mobile as long data member and City as String data member.
Class has following method:
1. set() for initializing data member and this method also validate the mobile
number.Mobile number must be 10 digit. Display “Invalid mobile number” if
mobile number is not 10 digit. And user also re-enter the valid mobile number.
2. display() to print the data.
3. searchByRollNo() which search student by roll number.
4. modifyByRollNo() which modify student name by using roll number.
Create a Main class in which N Students to be created. Use array of object.
Main class should display the following menu:
1.Display
2.search by Roll no
3.Modify name by Roll no
4.for Exit
This menu will stop if user press 4.
4 Write a JAVA program as per given instruction.
Create a class named “Student” in which you have to store data of students in instance
variables named “Rollno”, “Name”, “Percentage”.
Create necessary methods to perform following operations in “Student” class.
1. “set” -- for assigning data of Students.
2. “get” (without return type & without argument) -- for displaying data of individual
Students.
3. “get” (without return type & with argument) -- for displaying data of all Students.
4. "sort" -- for sorting data of Students based on their Rollno in ascending order without
using
inbuilt method.
5. "find" -- for searching data of Students based on their Rollno.
6
L.J Institute of Engineering and Technology, Ahmedabad.
Computer Programming Using JAVA-I Question Bank SEM-I 2023
(Take Rollno from user using scanner class and if Rollno exist then display
details using get() method else print message "Record Not Found!!")
6. "update" -- for updating the name of a Student to Upper case based on their Rollno.
(Take Rollno from user using scanner class and if Rollno exist then Update
name to Upper case and then display details of all student using get() method
else display old record)
Note: You have to create methods with the name same as given above and set category
of “get"
methods as per instruction, for remaining methods you can set as per your understanding.
-- Create another class named "RUN" which includes the main method. (use array of
objects
concept)
-- Take size of array through command line argument, call methods of "Student" class
from
this class.
5 Write a JAVA program that executes following Result System.
• TASK 1:
Create a class College. Create a method login for a new faculty entering marks first time.
Login
method first displays message "Welcome to Online Result Portal". Faculty must Login
with
the default password 1234. If password entered does not match with the default
password, the
screen displays "Invalid Password" and provides chance to re-enter the password. The
total
number of attempts must be only 2. After 2 wrong attempts the screen must display the
message "Your account is locked for 1 hour" and exit from the program.
If the password matches with the default password, display message "Successful Login".
The
next step must need to be to change the default password using method resetPassWord.
resetPassWord method first displays message "Reset Password". New entered password
must
satisfy below conditions:
1. Password length must be 4 digits only. (Ex: 2134)
2. It should have only digits.
3. No alphabet or space or special characters allowed.
If password not entered as per above condition then display message "Invalid
combination,
enter valid password". This method must execute until password changed successfully.
• TASK 2:
7
L.J Institute of Engineering and Technology, Ahmedabad.
Computer Programming Using JAVA-I Question Bank SEM-I 2023
After successfully changing the password, call a method enterMarks to enter marks of 5
students for three subjects Maths, Physics and Java using set method. Maximum marks
for
each subject is 25. Create method enterMarks by passing array as argument. Declare at
least 5
students.
• TASK 3:
Create method calculateSubjectTotal by using call by reference concept. Calculate
percentage
of three subjects. Create method display to print percentage of each subject. Create
method
subjectRanking to find Highest ranking subject based on percentage by using call by
value
concept. Last statement of program should Print message: "Highest Result is in subject :
(Subject Name) ".
EX: Highest Result is in subject : Maths
Use above all created methods.