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

HomeWork On Chap-4

1. This document contains source code submissions for programming exercises from an Object Oriented Programming course. 2. The first exercise involves writing a program to calculate total ticket sales from three types of concert seats using one main class. 3. Another exercise has the student write a program to calculate the area of a circular region using an inner and outer radius, defining a Circle class. 4. A third exercise modifies a Bicycle class to assign an owner object instead of just a name and models it after a LibraryCard class.

Uploaded by

Shantanu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

HomeWork On Chap-4

1. This document contains source code submissions for programming exercises from an Object Oriented Programming course. 2. The first exercise involves writing a program to calculate total ticket sales from three types of concert seats using one main class. 3. Another exercise has the student write a program to calculate the area of a circular region using an inner and outer radius, defining a Circle class. 4. A third exercise modifies a Bicycle class to assign an owner object instead of just a name and models it after a LibraryCard class.

Uploaded by

Shantanu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Homework-04

Course Title: Object Oriented Programming

Course Code: PMSCS 602


Chapter: 4
Submission Date: 30 APR 2021

Submitted To:
Dr. Md. Ezharul Islam
Associate Professor
Dept. of CSE.
Jahangirnagar University.
Submitted By:
Shantanu Mazumder
Student Roll: CSE202101154
Jahangirnagar University
CSE, PMSCS.
 Level 1 Programming Exercise:
6. Write a program that computes the total ticket sales of a concert. There are three types of
seatings: A, B, and C. The program accepts the number of tickets sold and the price of a ticket
for each of the three types of seats. The total sales are computed as follows:

totalSales = numberOfA_Seats * pricePerA_Seat +numberOfB_Seats * pricePerB_Seat +


numberOfC_Seats * pricePerC_Seat;

Write this program, using only one class, the main class of the program.

Answer: The source code of this program is given below:


Output:

9. Write a program that computes the area of a circular region (the shaded area in the
diagram), given the radii of the inner and the outer circles, ri and ro, respectively. We compute
the area of the circular region by subtracting the area of the inner circle from the area of the
outer circle. Define a Circle class that has methods to compute the area and circumference. You
set the circle’s radius with the setRadius method or via a constructor.

Answer: Source Code is given below:


Output:
10. Modify the Bicycle class so instead of assigning the name of an owner (Student), you can
assign the owner object itself. Model this new Bicycle class after the LibraryCard class.

Answer: Source Code is given below:

Output:
 Level 2 Programming Exercise:
12. Write a program that displays the recommended weight (kg), given the user’s age and
height (cm). The formula for calculating the recommended weight is

recommendedWeight = (height - 100 + age / 10) * 0.90

Define a service class named Height and include an appropriate method for getting a
recommended weight of a designated height.

Answer: Source Code is given below:


Output:

 Development Exercise:
16. Write a program that accepts the unit weight of a bag of coffee in pounds and the number
of bags sold and displays the total price of the sale, computed as follows:

totalPrice = bagWeight * numberOfBags * pricePerLb;

totalPriceWithTax = totalPrice + totalPrice * taxrate;

Define and use a programmer-defined CoffeeBag class. Include class constants for the price per
pound and tax rate with the values $5.99 per pound and 7.25 percent, respectively.
Answer: Source Code is given below:
Output:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy