0% found this document useful (0 votes)
17 views5 pages

Lab Manual 1

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)
17 views5 pages

Lab Manual 1

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/ 5

OBJECT ORIENTED

PROGRAMMING LAGNUAGE
LAB MANUAL
For BSIT

Prepared By
Muhammad Munawar Ahmed
Appendix - B

C PROGRAMMING LAB SHEETS

Dear Students,
Welcome to Programming Fundamentals Lab. For the practical works of C++ programming, you have to
complete at least eight to ten lab activities throughout the course. These lab sheets will guide you to prepare
for programming and submission of lab reports. Further, it helps you to understand practically about the
knowledge of programming. You can use this lab guide as the base reference during your lab.
You have to submit lab report of previous lab into corresponding next lab during when your instructor shall
take necessary VIVA for your each lab works. For your reference, “how to write a complete lab report?”
is being prepared as sample report for LAB sheet #1 and LAB sheet #2 in this manual. For the rest of your
labs, please follow the reporting style as provided. Your lab report to be submitted should include at least
the following topics.
1. Cover page
2. Title
3. Objective(s)
4. Problem Analysis
5. Algorithm
6. Coding
7. Output (compilation, debugging & testing)
8. Discussion & Conclusion.
On each lab, you have to submit the report as mentioned above however for additional lab exercises; you
have to show the coding and output to your instructor.
Note: The lab exercises shall not be completed in a single specific lab. Students are encouraged to complete
the programming questions given in the exercise prior to come to the lab hour and do the lab for the given
title/objectives.
(Sample Cover page, please use your own university/college name& department for your lab report submission)

Department of Information Technology, BJ Campus


The Islamia University of Bahawalpur
LAB Sheet #1

Programming Fundamentals Lab Report Submitted By:

Name: ___________________

RollNo: ___________________

Submitted To:

Department of Information Technology

Lab Date: Marks & Signature

Submission Date:
Sample Problem
Write a Program to calculate and display the volume of a CUBE having its height (h=10cm), width
(w=12cm) and depth (8cm).

Objective(s):
To be familiar with syntax and structure of JAVA-programming.
To learn problem solving techniques using JAVA.
Problem Analysis:
The problem is to calculate the volume of a CUBE having its inputs parameters identified as:Height (integer
type), width (integer type) and depth (integer type). The output of the program is to display the volume;
hence the output parameter is identified as vol (integer type). During the processing or calculation phase,
we don’t need any extra parameters (variables) for this problem.
The volume of the cube is the multiplication of its height, width and depth, hence the mathematical formula
to calculate volume is:
vol = height* width* depth. (vol = h*w*d)
Input Processing Output Necessary header
variables variables/calculations variables files/functions/macros
h(int) vol = h*w*d vol iostream
w(int) (int)
d(int)
Algorithm:
1. Start
2. Define variables: h(int), w(int), d(int), vol(int)
3. Assign value to variables: h = 10, w=12, d=8
4. Calculate the volume as: vol = h*w*d
5. Display the volume (vol)
6. Stop

Code:

//Following code is written and compiled in ECLIPSE IDE

Output (Compilation, Debugging & Testing)


The Volume of the cube is: 960

Discussion and Conclusion


This is the first code written in JAVA program. The program is focused on the calculation of volume of a
cube for the given height, width and depth. From this lab, I understood the basic structure of JAVA
programming including the meaning of header files & steps of problem solving. Hence, volume of a cube
is calculated and displayed.
Lab exercises (please code yourself and show the output to instructor):
1. Write a program to display “hello world” in JAVA.
2. Write a program to add two numbers (5&7) and display its sum.
3. Write a program to multiply two numbers (10&8) and display its product.
4. Write a program to calculate area of a circle having its radius given by the user.
5. Write a program to calculate area of an ellipse having its axes (minor=4cm, major=6cm).
6. Write a program to calculate simple interest for a given P=4000, T=2, R=5.5. (I = P*T*R/100)
7. Write a program that asks the user to enter two numbers, obtains the two numbers from the user and
prints the sum, product, difference, and quotient of the two numbers.
8. (Displaying Shapes with Asterisks) Write a program that prints a box, an oval, an arrow and a
diamond using System.out.println statements only.
9. Ramesh’s basic salary is input through the keyboard. His dearness allowance is 40% of basic salary,
and house rent allowance is 20% of basic salary. Write a program to calculate his gross salary.
10. The distance between two cities (in km.) is input through the keyboard. Write a program to convert
and print this distance in meters, feet, inches and centimeters.
11. If the marks obtained by a student in five different subjects are input through the keyboard, find out
the aggregate marks and percentage marks obtained by the student. Assume that the maximum marks
that can be obtained by a student in each subject is 100.
12. Temperature of a city in Fahrenheit degrees is input through the keyboard. Write a program to
convert this temperature into Centigrade degrees.
13. The length & breadth of a rectangle and radius of a circle are input through the keyboard. Write a
program to calculate the area & perimeter of the rectangle, and the area & circumference of the circle.
14. Two numbers are input through the keyboard into two locations C and D. Write a program to
interchange the contents of C and D.
15. If a five-digit number is input through the keyboard, write a program to calculate the sum of its
digits(Hint: Use the modulus operator ‘%’)
16. If a five-digit number is input through the keyboard, write a program to reverse the number.
17. If a four-digit number is input through the keyboard, write a program to obtain the sum of the first
and last digit of this number.

You might also like