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

HomeWork - 05

This document contains a homework assignment for an Object Oriented Programming course. It includes 19 programming exercises to write code for various tasks like calculating recommended weights based on height, computing triangle properties, converting numbers to Roman numerals, and calculating order totals with discounts. The student has provided the source code and output for each exercise.

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)
128 views

HomeWork - 05

This document contains a homework assignment for an Object Oriented Programming course. It includes 19 programming exercises to write code for various tasks like calculating recommended weights based on height, computing triangle properties, converting numbers to Roman numerals, and calculating order totals with discounts. The student has provided the source code and output for each exercise.

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

Homework-05

Course Title: Object Oriented Programming

Course Code: PMSCS 602


Chapter: 5
Submission Date: 03 jun 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:
9. One million is 106 and 1 billion is 109. Write a program that reads a power of 10 (6, 9, 12,
etc.) and displays how big the number is (Million, Billion, etc.). Display an appropriate message
for the input value that has no corresponding word. The table below shows the correspondence
between the power of 10 and the word for that number.

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


Output:

10. Write a program RecommendedWeightWithTest by extending the RecommendedWeight


(see Exercise 8 on page 209). The extended program will include the following test:

if (the height is between 140cm and 230cm)

compute the recommended weight

else

display an error message

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


Output:
11. Extend the RecommendedWeightWithTest program in Exercise 12 by allowing the user to
enter his or her weight and printing out the message You should exercise more if the weight is
more than 10 lb over the ideal weight and You need more nourishment if the weight is more
than 20 lb under the recommended weight.

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


Output:

15. Define a class called Triangle that is capable of computing the perimeter and area of a
triangle, given its three sides a, b, and c, as shown below. Notice that side b is the base of the
triangle.The design of this class is identical to that for the Ch5Circle class from Section 5.1.
Define a private method isValid to check the validity of three sides. If any one of them is invalid,
the methods getArea and getPerimeter will return the constant INVALID_DIMENSION.

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


Output:

17. At the end of movie credits you see the year movies are produced in Roman numerals, for
example, MCMXCVII for 1997. To help the production staff determine the correct Roman
numeral for the production year, write a program that reads a year and displays the year in
Roman numerals.

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


Output:
19. Combine Exercises 18 and 25 of Chap. 3 to compute the total charge including discount and
shipping costs. The output should look like the following:

Number of Bags Ordered: 43 - $ 236.50

Discount

5% - $ 11.83

Boxes Used:

1 Large - $1.80

2 Medium - $2.00

Your total charge is: $ 228.47

Answer: The source code of this program 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