Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views

Lab 3 Assignment_ Programming-1

The document contains Java code examples for checking if a number is even or odd, and verifying if a number falls within a specific range. It includes three classes: EvenOddChecker, RangeChecker (for numbers between 10 and 20), and another RangeChecker (for numbers less than 10 or greater than 20). Each example provides output statements based on the test values provided in the code.

Uploaded by

qqxxxnnn
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Lab 3 Assignment_ Programming-1

The document contains Java code examples for checking if a number is even or odd, and verifying if a number falls within a specific range. It includes three classes: EvenOddChecker, RangeChecker (for numbers between 10 and 20), and another RangeChecker (for numbers less than 10 or greater than 20). Each example provides output statements based on the test values provided in the code.

Uploaded by

qqxxxnnn
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Programming - 1

2024
Student Name: Mohand Al-Qarni
IDstudent: 600443397
1. public class EvenOddChecker {
2. public static void main(String[] args) {
3. int number =5; //You can number to test other values
4.
5. if(number%2==0){
6. System.out.println("The number is even .");
7. }else{
8. System.out.println("The number is odd .");
9. }
10. }
11. }

1
‫‪:‬مخرجات‪ :‬المثال السابق اختبار القيمة ‪ 10‬هل هي زوجيه او فردية‬

‫‪:‬مخرجات‪ :‬المثال السابق اختبار القيمة ‪ 5‬هل هي زوجيه او فردية‬

‫‪2‬‬
1. public class RangeChecker {
2. public static void main(String[] args) {
3. int number =15; //You can number to test other values
4.
5. //Check if the number is between 10 and 20
6. if(number >= 10 && number <=20){
7. System.out.println("The number is within the range of 10 to 20.");
8. }else{
9. System.out.println("The number is outside the range of 10 to 20.");
10. }
11. }
12. }

3
‫‪:‬مخرجات‪ :‬المثال السابق اختبار القيمة ‪ 15‬هل‬

‫‪:‬مخرجات‪ :‬المثال السابق اختبار القيمة ‪ 9‬هل‬

‫‪4‬‬
1. public class RangeChecker {
2. public static void main(String[] args) {
3. int number =25; //You can number to test other values
4.
5. //Check if the number is less than 10 or greater than 20
6. if(number < 10 || number > 20){
7. System.out.println("The number is either less than 10 or greater than 20 .");
8. }else{
9. System.out.println("The number is between 10 and 20 .");
10. }
11. }
12. }

5
‫‪:‬مخرجات‪ :‬المثال السابق اختبار القيمة ‪ 25‬هل‬

‫‪:‬مخرجات‪ :‬المثال السابق اختبار القيمة ‪ 15‬هل‬

‫‪6‬‬

You might also like