0% found this document useful (0 votes)
7 views

DevOps Assignment3

The document discusses creating classes for student details and courses. It involves pushing code to a GitHub repository with main and student_course_information branches, and merging the branches.

Uploaded by

dhruvap.312
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

DevOps Assignment3

The document discusses creating classes for student details and courses. It involves pushing code to a GitHub repository with main and student_course_information branches, and merging the branches.

Uploaded by

dhruvap.312
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Couse code : 22EBCP205 Course : DevOps Lab

DevOps Assignment – 2
Branching Concept
1. Create a Student class and write the functions for the following:
1. Display Student Name.
2. Display age of student, by accepting date of birth as parameter(DD-
MM-YYYY or YYYY-MM-DD) using "Date" Class
The above code should be pushed to new GitHub repository for "main"
branch.
------------------------------------------------------------------------------------------
Source code :
import java.util.Scanner;
import java.time.LocalDate;
import java.time.Period;
public class Student_Details {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter candidate name : ");
String student_name = scanner.nextLine();
System.out.print("Enter date of birth (YYYY-MM-DD) : ");
String input_dob = scanner.next();
Student_Details student1 = new Student_Details();
System.out.println("Details of student are : ");
student1.display_student_name(student_name);
student1.display_student_DOB(input_dob);
scanner.close();
}
KLE Tech, Hubli Department of Computer Application
Couse code : 22EBCP205 Course : DevOps Lab

public void display_student_name(String name) {


System.out.println("Student name : " + name);
}
public void display_student_DOB(String date) {
LocalDate dob = LocalDate.parse(date);
System.out.println("Student age : " + calculateAge(dob));
}
public static int calculateAge(LocalDate dob) {
LocalDate curDate = LocalDate.now();
// calculates the amount of time between two dates and returns the
years
if ((dob != null) && (curDate != null)) {
return Period.between(dob, curDate).getYears();
} else {
return 0;
}
}
}
Output :

KLE Tech, Hubli Department of Computer Application


Couse code : 22EBCP205 Course : DevOps Lab

Creating new repository :

Git commands :

KLE Tech, Hubli Department of Computer Application


Couse code : 22EBCP205 Course : DevOps Lab

Updated git repository :

KLE Tech, Hubli Department of Computer Application


Couse code : 22EBCP205 Course : DevOps Lab

2. Create a class to display the courses of respective semester and marks


obtained for each course. The same must be pushed to be new branch
"student_course_information", once the functionalities of "Student" and
"StudentCourses" class are executed successfully, the new branch should
be merged to the "main" branch.
------------------------------------------------------------------------------------------
Source code :
public class Student {
public static void main(String[] args) {
StudentCourses student01 = new StudentCourses(“Dhruva", 248);
student01.semester01(93, 82);
student01.semester02(90, 85);
student01.semester03(92,94);
}
}
class StudentCourses extends Student{
String student_name;
int student_usn;
public StudentCourses(String name, int usn){
this.student_name = name;
this.student_usn = usn;
display_details();
}
public void display_details(){
System.out.println("Student name : "+ student_name);

KLE Tech, Hubli Department of Computer Application


Couse code : 22EBCP205 Course : DevOps Lab

System.out.println("Student USN : "+ student_usn);


}
public void semester01(int C_Programming, int wed_Technology){
System.out.println("First semester courses and mark :- ");
// int C_Programming = 93;
// int wed_Technology = 82;
System.out.println("i. C Programming : "+ C_Programming);
System.out.println("ii. Wed Technology : "+ wed_Technology);
}
public void semester02(int Cpp_Programming, int FCO){
System.out.println("Second semester courses and mark :- ");
// int Cpp_Programming = 90;
// int FCO = 85;
System.out.println("i. C++ Programming : "+ Cpp_Programming);
System.out.println("ii. FCO : "+ FCO);
}
public void semester03(int applied_statistics, int
computer_networking){
System.out.println("Third semester courses and mark :-");
// int applied_statistics = 92;
// int computer_networking = 94;
System.out.println("i. Applied Statistics : "+ applied_statistics);
System.out.println("ii. Computer Networking : "+
computer_networking); } }
Output :

KLE Tech, Hubli Department of Computer Application


Couse code : 22EBCP205 Course : DevOps Lab

Git commands :

Creating new branch :

KLE Tech, Hubli Department of Computer Application


Couse code : 22EBCP205 Course : DevOps Lab

Updated git repository :

KLE Tech, Hubli Department of Computer Application


Couse code : 22EBCP205 Course : DevOps Lab

KLE Tech, Hubli Department of Computer Application


Couse code : 22EBCP205 Course : DevOps Lab

KLE Tech, Hubli Department of Computer Application


Couse code : 22EBCP205 Course : DevOps Lab

KLE Tech, Hubli Department of Computer Application

You might also like