Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

ASSIGNMENT NO 2

Course Code: COMP-2111 Course Title: Object Oriented Programming Class: BS(CS) 2nd Semester
Shift: Morning (A) Submission Deadline: 16-02-2024 Instructor: Usman Rafi

Note:
1. This will be an individual assignment and should be implemented in Java programming language.
2. Assignment must be your original work and should be in proper assignment format.
3. Mention all your details on the cover page of assignment including your name, roll number, class,
semester, and course code and course title.
4. Properly organize your assignment and pin up all the pages properly.
5. Scan your assignment using Microsoft Lens and save it as PDF file. Send the PDF file to CR on or
before the deadline. On return to university, submit your assignment file. After deadline, no assignment
will be acceptable.

ASSIGNMENT TASKS

DEVELOP THE FOLLOWING PROGRAMS IN JAVA USING OBJECT ORIENTED


PROGRAMMING TECHNIQUE
Task No. 1: Write a program that inputs six-digit number. Program should calculate the product of individual
digits.
Task No. 2: Write a program that inputs a character and displays next two characters.
Task No. 3: Write a program that inputs your age in years (integer only). The program should display your age
in months, days, hours, minutes and seconds.
Task No. 4: Write a program that inputs an angle value and calculate the sin, cos and tan of this angle.
Task No. 5: Write a program that inputs weight of sugar in pounds. Program should convert the weight into
kilograms and grams and display on the screen.
Task No. 6: Write a program that inputs two points P(x1,y1) and P(x2,y2). The program should calculate the
distance between these two points using the distance formula.
Task No. 7: Write a program to calculate the volume of a cube using the formula: V = length * width * height.
Task No. 8: Write a program that inputs 5-digit binary number and calculates its equivalent octal number.
Task No. 9: Write a program that inputs purchase price, sale price of a book and number of copies sold during a
week. Program should display the total profit earned by the shopkeeper.
Task No. 10: The average of a car is 10.5 Kilometers in 1 liter petrol. The car owner wants to go to Islamabad
from Faisalabad via motorway. The distance is approximately 400 Kilometers. Write a program to calculate the
total money required by the owner to travel to Islamabad considering that price of petrol is 150.23 rupees per liter
and tool tax of rupees 750.
Task No. 11: Write a program that inputs total chapters of a book. Program should also input the number of
chapters a student can complete in one day. Program should calculate and display that how many hours a student
requires to complete all the chapters of this book.
Task No. 12: Write a program that inputs distance covered in miles from the user. Program should convert the
distance into kilometers and show on the screen.
Task No. 13: Write a program that inputs five numbers and display the output using a single System.out.println()
statement as follows:
Number: 1 2 3 4 5
Square: 1 4 9 16 25
Cube: 1 8 27 64 125
Task No. 14: Write a program that inputs attendance of a whole week (5 days) in a course. The program should
calculate the attendance percentage of the student.
Task No. 15: Write a program that inputs area of a circle. The program should calculate and display the diameter
and circumference of the circle.
Task No. 16: Write a program that inputs hypotenuse and base of a right-angle triangle. The program should
calculate and display the altitude of that triangle.
Task No. 17: Write a program that inputs the x and y coordinates of two points P and Q from the user. The
program should display the equation of line formed by connecting these two points on the screen.
Task No. 18: Write a program that takes temperature in Fahrenheit as input from a user. The program should
convert and display the temperature in Centigrade and Kelvin scale.
Tak No. 19: Write a program that inputs sides of a rectangle. The program should calculate the area and perimeter
of the rectangle on the screen.
Task No. 20: Write a program that inputs three numbers from user. The program should interchange the contents
of these variables without using a fourth variable.
Task No. 21: Suppose a shopkeeper has sold X KGs of apple with a price of Y rupees including 10% profit. Write
a program that inputs the number of KGs of apple sold and the sale price from user. After input the program
should calculate and display the purchase price of 1 KG apples.
Task No. 22: Write a program that inputs radius of sphere and calculates its volume.
Task No. 23: Write a program that inputs two numbers: base and power. After the input the program should
calculate base raise to the power of power.
Task No. 24: Write a program that inputs a string from user like name. The program should reverse the string
and display it on screen.
Task No. 25: Write a program that inputs total marks and obtained marks of six courses. The program should
calculate and display the total obtained marks and overall percentage.

Good Luck

You might also like