Oop Lab 1 Report
Oop Lab 1 Report
IT3100E-750861-Object-Oriented
Programming lab
Full name Phan Đăng Đạt
Student ID 20235908
I,First Program
2.2.1,Write the ”HelloWorld” Program
Code:
package lab_01;
strNum1 = JOptionPane.showInputDialog(null,
"Please input the first number: ", "Input the first number",
JOptionPane.INFORMATION_MESSAGE);
strNotification += strNum1 + " and ";
strNum2 = JOptionPane.showInputDialog(null,
"Please input the second number: ", "Input the second
number",
JOptionPane.INFORMATION_MESSAGE);
strNotification += strNum2;
JOptionPane.showMessageDialog(null, strNotification,
"Show two numbers",
JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
2.2.5, Write a program to calculate sum,
difference, product, and quotient of 2
double numbers which are entered by
users.
Code:
package lab_01;
import java.util.Scanner;
Case 1:a=10,b=5
Case 2:a=0,b=5
Q2:Write a program to solve:The system of
first-degree equations with two variable
Code:
package lab_01;
import java.util.Scanner;
II,EXERCISE
Ex6.1:Write “ChoosingOption” Program
Code:
package lab_01;
import javax.swing.JOptionPane;
System.exit(0);
}
}
if (year < 1) {
System.out.println("Invalid year. Please enter again.");
} else {
break;
}
}
int days;
switch (month) {
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
days = 31;
break;
case 4: case 6: case 9: case 11:
days = 30;
break;
case 2:
// Check for leap year
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 ==
0)) {
days = 29;
} else {
days = 28;
}
break;
default:
days = 0; // This should never be reached due to
validation
}
Case 1:month:oct,year:-100
Case 2:month:-oct,year:100
Case 3:month:oct,year:100
Case 4:month:Oct,year:100
Case 5:month:Oct.,year:100
Case 6:month:10,year:100
Ex6.5,Write a Java program to sort a
numeric array and calculate the sum and
average value of array elements
Code:
package lab_01;
import java.util.Arrays;
import java.util.Scanner;