java_aat_2
java_aat_2
COLLEGE OF ENGINEERING
(Autonomous college under VTU)
Bull Temple Rd, Basavanagudi, Bengaluru, Karnataka
560019 2023-2025
Department of Computer Applications
“Java
Programming”
By
FAADIL KHALEEL
import java.util.Scanner;
public class sumrecursion{
public static int sum(int arr[],int l){
if (l == -1)
{
return 0;
}
return arr[l]+sum(arr,l-1);
}
outPut:
2.LCM of two numbers using recursion
3.Define a class Employee and Salary Classes with necessary members and methods. Print the
salary slip of an employee.
class Employee {
private String name;
private String id;
private String department;
private Salary salary;
class Salary {
private double basic;
private double hra;
private double da;
import java.util.Scanner;
class TimeConverter {
private int sec;
scanner.close();
}
}
5. Check whether the entered character is a vowel or consonant.
import java.io.*;
class vowelorcons {
static void Vowel_Or_Consonant(char y)
{
if (y == 'a' || y == 'e' || y == 'i' || y == 'o'
|| y == 'u' || y == 'A' || y == 'E' || y == 'I'
|| y == 'O' || y == 'U')
System.out.println("It is a Vowel.");
else
System.out.println("It is a Consonant.");
}
static public void main(String[] args)
{
Vowel_Or_Consonant('y');
}
}
6. Check whether entered character is alphabet or not, If yes check whether uppercase or lowercase
import java.util.Scanner;
if ((inputChar >= 'A' && inputChar <= 'Z') || (inputChar >= 'a' && inputChar <= 'z')) {
if (inputChar >= 'A' && inputChar <= 'Z') {
System.out.println("The entered character is an uppercase alphabet.");
} else {
System.out.println("The entered character is a lowercase alphabet.");
}
} else {
System.out.println("The entered character is not an alphabet.");
}
scanner.close();
}
}