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

Proje01 Java

Java

Uploaded by

berkc766
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)
18 views5 pages

Proje01 Java

Java

Uploaded by

berkc766
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

1 Program to Determine the Type of a Triangle

1.1 Objective
Create a Java program that accepts three integers representing the lengths of the sides of a triangle. The program
should determine whether these sides can form a triangle. If they do, the program should further classify the
triangle as equilateral, isosceles, or scalene.

1.2 Requirements
• Prompt the user to enter three positive integers.

• Check if the three sides satisfy the triangle inequality theorem:

a+b>c
a+c>b (1)
b+c>a

• If the sides form a triangle:

– Determine if it is an equilateral triangle (all sides equal).


– Determine if it is an isosceles triangle (two sides equal).
– Determine if it is a scalene triangle (all sides different).
• If the sides do not form a triangle, display an appropriate message.

1.3 Example
• Input: a = 5, b = 5, c = 8
• Output: Isosceles triangle.

1
2 Simple Calculator Program
2.1 Objective
Design a Java program that functions as a simple calculator. The program should perform basic arithmetic opera-
tions (+, -, *, /) on two numbers input by the user.

2.2 Requirements
• Prompt the user to enter two numbers (integers or decimals).

• Prompt the user to select an arithmetic operation (+, -, *, /).


• Perform the selected operation on the two numbers.
• Display the result of the computation.
• If the user attempts to divide by zero, display an appropriate error message.

• If the user selects an invalid operation, display an error message.

2.3 Example
• Input:
– Number 1: 10
– Number 2: 5
– Operation: +

• Output: Result: 15.0

2
3 Intersection of Two Circles
3.1 Objective
Develop a Java program that determines whether two circles intersect, are separate, or one is inside the other
without intersecting.

3.2 Requirements
• Prompt the user to enter the center coordinates and radii of two circles:

– Circle 1: (x1 , y1 ), r1
– Circle 2: (x2 , y2 ), r2
• Calculate the distance between the centers of the two circles:
p
d = (x2 − x1 )2 + (y2 − y1 )2

• Determine the relationship between the circles based on d, r1 , and r2 :


– If d > r1 + r2 , the circles are separate and do not intersect.
– If d < |r1 − r2 |, one circle is inside the other and they do not intersect.
– If d = 0 and r1 = r2 , the circles are coincident (infinite intersection points).
– Otherwise, the circles intersect.
• Display the appropriate relationship between the circles.

3.3 Example
• Input:
– Circle 1: x1 = 0, y1 = 0, r1 = 5
– Circle 2: x2 = 8, y2 = 0, r2 = 5

• Output: The circles intersect.

3
4 Determining the Position of a Point in the Coordinate Plane
4.1 Objective
Write a Java program that determines the position of a point in the Cartesian coordinate plane based on its x and
y coordinates.

4.2 Requirements
• Prompt the user to enter the x and y coordinates of a point.

• Determine the location of the point:


– Quadrant I: x > 0 and y > 0
– Quadrant II: x < 0 and y > 0
– Quadrant III: x < 0 and y < 0
– Quadrant IV: x > 0 and y < 0
– On the X-axis: y = 0 and x ̸= 0
– On the Y -axis: x = 0 and y ̸= 0
– At the origin: x = 0 and y = 0
• Display a message indicating the point’s location.

4.3 Example
• Input: x = -5, y = 5

• Output: The point is in the second quadrant.

4
5 Calculating Date from Day Number
5.1 Objective
Develop a Java program that calculates the month and day corresponding to a given day number in the year (from
1 to 365), assuming it is not a leap year.

5.2 Requirements
• Prompt the user to enter a day number between 1 and 365.

• Validate that the input is within the specified range.


• Calculate the corresponding month and day.
– Use the standard number of days in each month (not accounting for leap years):
∗ January: 31 days
∗ February: 28 days
∗ March: 31 days
∗ April: 30 days
∗ May: 31 days
∗ June: 30 days
∗ July: 31 days
∗ August: 31 days
∗ September: 30 days
∗ October: 31 days
∗ November: 30 days
∗ December: 31 days
• Display the calculated date in the format Day.Month (e.g., 15.4 for April 15th).

5.3 Example
• Input: Day Number = 100
• Output: Date: 10.4

You might also like