GRADE 9.JAVA - Function Argument Programs
GRADE 9.JAVA - Function Argument Programs
1. WAP to input your age and find if you are eligible for voting or not.
public class p1
{
public static void main(int age)
{
if(age>=18)
System.out.println("You are eligibile to Vote");
else
System.out.println("You are eligibile to Vote");
}
}
2. WAP to input marks in 3 Subject and calculate total , avg. If average is greater
than 80, Option is Science, else if greater or 34 than option is commerce else
appear next year.
public class p1
{
public static void main(int marks1, int marks2, int marks3)
{
int avg=(marks1+marks2+marks3)/3;
if(avg>=80)
System.out.println("You are eligible for Science Stream");
else if(avg>=34)
System.out.println("You are eligible for Commerce Stream");
else
System.out.println("You might have not Pass. Clear the exam next session");
} }
public class p1
{
public static void main(int num)
{
if(num>0)
System.out.println("Entered number is positive number");
else if(num<0)
System.out.println("Entered number is negative number");
else
System.out.println("Entered number is zero");
}
}
8. WAP to input the year and check if it is leap year (leap year is
consider when it is divisible by 400 or 4 or both , century (100th year).
public class p1
{
public static void main(int year)
{
System.out.println(“The entered year by user is: “ +year);
if(year%400==0 ||year%4==0)
System.out.println("The Entered year is a Century Leap Year");
else if(year%4==0)
System.out.println("The Entered year is a Leap Year");
else
System.out.println("The Entered year is not a Leap Year");
}
10. WAP to input your name and total marks and check if eligible for
honour society (total above 500/out of 600)
public class p1
{
public static void main(String name, int tm)
{
System.out.println(“The entered name by user is: “ +name);
System.out.println(“The total marks entered by user is: “ +tm);
12. Write a program to check whether entered digit by user contains single
digit, double digit or triple digit and more.
public class p1
{
public static void main(int digit)
{
System.out.println(“The digit entered by the user is: “ +digit);
if(digit>=0 && digit<=9)
System.out.println("The Entered number is Single digit");
else if(digit>=10 && digit<=99)
System.out.println("The Entered number is Double digit");
else
System.out.println("The Entered number is Triple digit or more");
}
13. Write a program to check the entered character is Upper case Vowel or
Lower Case Vowel or a Consonant.
public class p1
{
public static void main(char ch)
{
System.out.println(“The entered character by user is= ”+ch);
if(ch==’A’||ch==’E’||ch==’I’||ch==”O”||ch==’U’)
System.out.println("The Entered character is Upper Case Vowel");
else if(ch==’a’||ch==’e’||ch==’i’||ch==”o”||ch==’u’)
System.out.println("The Entered character is Upper Case Vowel");
else
System.out.println("The Entered character is a Consonant");
}
**************************************************************