0% found this document useful (0 votes)
4 views

GRADE 9.JAVA - Function Argument Programs

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

GRADE 9.JAVA - Function Argument Programs

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

SMT.

SUNITIDEVI SINGHANIA SCHOOL, THANE


GRADE 9/COMPUTER APPLICATIONS/TERMI/2024-2025

JAVA PROGRAMS USING FUNCTION ARGUMENTS

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");
} }

3. WAP to input a number and find it is odd or even.


public class p1
{
public static void main(int num)
{
if(num%2==0)
System.out.println("Entered number is Even Number");
else
System.out.println("Entered number is Odd Number");
}
}
4. WAP to input a number and find if it is positive, negative or zero.

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");
}
}

5. WAP to input 2 numbers and find the largest among them


public class p1
{
public static void main(int num1, int num2)
{
System.out.println(“Two numbers entered by user are:” +num1+ “ ”+num2);
if(num1>num2)
System.out.println("Entered number1 is greater than number 2");
else
System.out.println("Entered numbe2 is greater than number1");
}
}

6. WAP to input 3 angles of triangle and check if triangle is possible or not.


public class p1
{
public static void main(int a1, int a2, int a3)
{
System.out.println(“Three angles entered by user are:” +a1+ “ ”+a2+ “ “+a3);
if(a1+a2+a3==180)
System.out.println("With given measures the Triangle is Possible");
else
System.out.println("With given measures the Triangle is not Possible");}
}

7. ⁠WAP to input 3 sides of triangle and check if it is equilateral,


isosceles or scalene triangle.
public class p1
{
public static void main(int s1, int s2, int s3)
{
System.out.println(“Three sides entered by user are:” +s1+ “ ”+s2+ “ “+s3);
if(s1==s2&&s2==s3&&s1==s3)
System.out.println("The triangle formed is Equilateral Triangle since all sides are
equal");
else if(s1==s2||s2==s3||s1==s3)
System.out.println("The triangle formed is Isoceles Triangle since any two sides are
equal");
else
System.out.println("The triangle formed is Scalene Triangle since none of the sides
are equal");
}

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);

if(tm>=500 && tm <=600)


System.out.println(name+ “ is eligible or Honour Society");
else
System.out.println(name+ “ is not eligible or Honour Society"");
}

11. Write a program to calculate the simple interest by accepting rate of


interest, time and principle amount from the user.
public class p1
{
public static void main(float rate, int time, float principle)
{
System.out.println(“The rate of interest entered=” + rate);
System.out.println(“The time period entered by user=” +time);
System.out.println(“The principle amount entered by user=” +principle);
float si=(principle*rate*time)/100;
System.out.print(“The simple interest calculate =” +si);
}
}

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");
}

**************************************************************

You might also like