0% found this document useful (0 votes)
54 views3 pages

Week 5 - Laboratory Activity 1: Using Joptionpane Class For The User Input

John completed a Java programming lab activity that involved determining which quadrant of the Cartesian plane a point belongs to based on its x and y coordinates. The program prompts the user to input the x and y coordinates, converts them to integers, then uses conditional statements to check if the point is in Quadrant I, II, III or IV. If the coordinates are 0,0 it displays "Point of Origin". John provided the source code, screenshots of sample outputs including for the point of origin, and a selfie with the running program.

Uploaded by

John Rey Ubas
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)
54 views3 pages

Week 5 - Laboratory Activity 1: Using Joptionpane Class For The User Input

John completed a Java programming lab activity that involved determining which quadrant of the Cartesian plane a point belongs to based on its x and y coordinates. The program prompts the user to input the x and y coordinates, converts them to integers, then uses conditional statements to check if the point is in Quadrant I, II, III or IV. If the coordinates are 0,0 it displays "Point of Origin". John provided the source code, screenshots of sample outputs including for the point of origin, and a selfie with the running program.

Uploaded by

John Rey Ubas
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/ 3

Week 5 - Laboratory Activity 1

Name: _John Rey J. Ubas____________________________________________ Score:


Student Number: 202150559___________ Date: 03/03/2023____________
Section/Schedule _29052 / Monday 10:30AM – 1:30PM___________ ______
Subject: Object Oriented Programming Lab Professor:_Mr. Archie G. Santiago_ 30

Objectives:
a. Design and perform correct usage of a Java programming constructs using Conditional
Statements and using JOptionPane Class for the User Input.

A. Using Conditional Statement

Problem: Create a Java Application that will let the user enter two numbers (positive or negative
integer value) that will represent the x-coordinate and y-coordinate of a point in a Cartesian
Plane. Then determine if the inputted coordinates of a point belong to Quadrant I, Quadrant
II, Quadrant III, or Quadrant IV. Refer to the figure below (Cartesian Plane).
Note: If the Coordinates are 0,0 display the Remark : “Point of Origin”.

• Point(3,2)
Point(3,2) is in
Quadrant 1.

Directions:

Step 1. Open your NetBeans IDE.

Step 2. Write the intended program for the problem. Note: use Conditional Statements.

Step 3. Save your program using the written Class Name as the File Name and with the File
Extension name – .java.

Step 4. Compile and Run your Java Application.


Step 5. Provide the following:

a. Source Code Listing. (10 points)

package week5labact1;

import javax.swing.JOptionPane;
public class Week5LabAct1 {

public static void main(String[] args) {

String abx = JOptionPane.showInputDialog(null, "Present or nter the x-coordinate: ");


int x = Integer.parseInt(abx);
String aby = JOptionPane.showInputDialog(null, "Present or enter the y-coordinate:");
int y = Integer.parseInt(aby);

if(x > 0 && y > 0){


JOptionPane.showMessageDialog(null, "Point ("+ x +","+ y +") is located in the 1st
Quadrant!");
}
else if(x < 0 && y > 0)
{
JOptionPane.showMessageDialog(null, "Point ("+ x +","+ y +") is located in the 2nd
Quadrant!");
}
else if(x < 0 && y < 0)
{
JOptionPane.showMessageDialog(null, "Point ("+ x +","+ y +") is located in the 3rd
Quadrant!");
}
else if(x > 0 && y < 0)
{
JOptionPane.showMessageDialog(null, "Point ("+ x +","+ y +") is located in the 4th
Quadrant!");
}
else{
JOptionPane.showMessageDialog(null, "Point of Origin!");
}
}

}
b. Screenshots of the Final Output (at least three, including the Point of Origin) (15
points)

OTHER QUADRANT OUTPUT:

c. Selfie with the Final Output (5 points)

You might also like