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

CSE 215 - Programming Language II Assigment#1

This document provides the details for Assignment #1 for the Programming Language II course in Fall 2022. It includes 4 problems to solve related to procedural vs object-oriented programming, population projections, calculating wind chill temperature, and determining the relationship between two circles. Students are instructed to cite sources as needed, submit their typed or handwritten answers and program output to Canvas by a deadline, and bring a hard copy to the next class.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

CSE 215 - Programming Language II Assigment#1

This document provides the details for Assignment #1 for the Programming Language II course in Fall 2022. It includes 4 problems to solve related to procedural vs object-oriented programming, population projections, calculating wind chill temperature, and determining the relationship between two circles. Students are instructed to cite sources as needed, submit their typed or handwritten answers and program output to Canvas by a deadline, and bring a hard copy to the next class.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CSE 215: Programming Language II

Assignment#1
Fall 2022

Name: ___________________________________
Student ID: ___________________________

Direction: You can consult any resources such as books, online references, and videos
for this assignment, however, you have to properly cite and paraphrase your answers
when it is necessary. There will be points for partial attempts. You should upload a copy
of your typed or handwritten answer to Canvas Monday, 31st October, 2022. Please also
submit a hardcopy of your assignment before the class begins on 2nd November,
Wednesday, 2022. Show your program and attach screenshots of your ouput.

Problem#1: Answer the following short questions


a) What are the differences between a procedural language and an object oriented
language? What are the advantages of an object oriented language?
b) What is the difference between bytecode (e.g. Java bytecode) and machine code?
c) What is a Java virtual machine (JVM)?
d) What advantages does Java have over procedural language like C?

Problem#2: (Population projection) Bangladesh’s population growth is projected based on the


following assumptions:

■ One birth in every 1 minutes


■ One death in every 2 minutes
■ One negative net migrant every 8 minutes (One person leaves country)

Write a program to display the population for each of the next five years. Assume that the
current population is 167,288,486, and one year has 365 days (no leap year has to be
considered). Hint: In Java, if two integers perform division, the result is an integer. The fractional
part is truncated. For example, 5 / 4 is 1 (not 1.25) and 10 / 4 is 2 (not 2.5). To get an accurate
result with the fractional part, one of the values involved in the division must be a number
with a decimal point. For example, 5.0 / 4 is 1.25 and 10 / 4.0 is 2.5.

Problem#3: (Science: wind-chill temperature) How cold is it outside? The temperature alone is
not enough to provide the answer. Other factors including wind speed, relative humidity, and
sunshine play important roles in determining coldness outside. In 2001, the National Weather
Service (NWS) implemented the new wind-chill temperature to measure the coldness using
temperature and wind speed. The formula is
where ta is the outside temperature measured in degrees Fahrenheit, v is the speed measured
in miles per hour, and twc is the wind-chill temperature. The formula cannot be used for wind
speeds below 2 mph or temperatures below -58°F or above 41°F.

Write a program that prompts the user to enter a temperature between -58°F and 41°F and a
wind speed greater than or equal to 2 then displays the wind-chill temperature. Use
Math.pow(a, b) to compute v0.16. Here is a sample run:

Problem#4: (Geometry: two circles) Write a program that prompts the user to enter the center
coordinates and radii of two circles and determines whether the second circle is inside the first
or overlaps with the first, as shown in Figure 1. (Hint: The formula for computing the distance is

. And Circle2 is inside circle1 if the distance between the two centers
<= r1 - r2 and circle2 overlaps circle1 if the distance between the two centers <=r1 + r2. Test
your program to cover all cases.)

Here are the sample runs:

Figure1: (a) A circle is inside another circle. (b) A circle overlaps another circle.

You might also like