Uploaded by Mahmuda Akter Nadia

OOP LR1 Completed.docx

advertisement
Green University of Bangladesh
Department of Computer Science and Engineering (CSE)
Faculty of Sciences and Engineering
Semester: (Spring, Year:2024), B.Sc. in CSE (Day)
Lab Report NO #1
Course Title: Object Oriented Programming Lab
Course Code: CSE 202
Section: 231 D1
Lab Experiment Name: C - Java Syntax Similarity: Array, Conditionals,
Loops
Student Details
Name
1.
ID
Mahmuda Akter Nadia
Lab Date
Submission Date
Course Teacher’s Name
231002001
: 22/02/2024
: 07/03/2024
: Mr. Saurav Chandra Das
Lab Report Status
Marks: …………………………………
Comments:..............................................
Signature:.....................
Date:..............................
TITLE OF THE LAB REPORT EXPERIMENT
C - Java Syntax Similarity: Array, Conditionals, Loops
OBJECTIVES/AIM
The objective of this lab is to design and implement a Java program covering the following
topics:
● Analyzing and comparing the similarities in syntax and functionality between the
programming languages C and Java
● Understanding java syntax, array conditions and loops
● Implementing different problems like Fibonacci numbers, and odd-even number checking
solved in Java.
Title: Checking of odd and even number
PROCEDURE / ANALYSIS / DESIGN
The flowchart to check odd and even number is mentioned below:
IMPLEMENTATION
The program imports the Scanner class from the java.util package. A class named OddEven has
been created. The main method takes a number from the user using scanner object. Then it
checks the number even or odd by conditional statements.
TEST RESULT / OUTPUT
All test cases have passed for different input values, including zero, positive and negative
integers, and large numbers. So, the program correctly identifies whether a given number is even
or odd.
Input
Output
-11
-11 is a Odd.
0
0 is Even.
29
29 is a Odd.
-101
-101 is a Odd.
10696
10696 is Even.
Title: Summation of factorial odd number series
PROCEDURE / ANALYSIS / DESIGN
The flowchart of main part to calculate the summation of factorial odd number series is:
IMPLEMENTATION
The program imports the Scanner class from the java.util package. A class named
FactorialOddNumSeries has some variables, a constructor, four methods. In the main method, it
takes input for x and n and checks n to be even. Then, it creates object of this class to run Result0
and display() method.
TEST RESULT / OUTPUT
All test cases have passed for different input values, including zero, positive and negative
integers, and large numbers. So, the program correctly identifies whether a given number is even
or odd.
Input
Output
x=3 n=6
7.199999999999999
x=3 n=11
Value of n must be even... Try again!
x=11 n=26
329292.2725487378
ANALYSIS AND DISCUSSION
The lab achieved its objective by checking a number odd or even and calculating the factorial
summation of odd number series. It took me time to understand the second problem and identify
how to solve it. I changed the logic in Result() method a few times to obtain an accurate
calculation. From this, I learned how to solve a problem step by step. This lab gave me a basic
idea about implementing Java syntax, array and conditional statements, and how to use Apache
NetBeans.
SUMMARY:
The lab report titled "C - Java Syntax Similarity: Array, Conditionals, Loops" explores the
syntactical similarities between C and Java in handling arrays, conditionals, and loops. It shows
that both languages have some similar structures, making it easier for programmers familiar with
one language to learn the other.
Download