Computer Science, asked by appu171, 1 year ago

write any 10 programs on java

Answers

Answered by anusha2001
2
public class pg14_1{   public void main(int a)   {       if(a>5)       System.out.println("The number is greater than five");    }}


public class pg14_2{    public void main(int a)    {        if(a>0)        System.out.println("The number is positive");        else        System.out.println("The numnber is negative");    }}

public class pg15_3{  public void main(int a)  {      if(a%2==0)      System.out.println("The number is even");      else       System.out.println("The number is odd");    }}


public class pg15_4{    public void main(int a)    {        if(a%7==0)        System.out.println("the number is divisible by 7");        else        System.out.println("the number is not divisible by 7");    }}

public class pg16_5{    public void main(int a, int b, int c)    {        int s=0;        s=a+b+c;        double avg;        avg=s/3;        if(avg<=40)        System.out.println("fail");        else        System.out.println("pass");    }}

public class pg17_6{    public void mian(int a, int b)    {        int s=0;        s=a+b;        double avg;        avg=s/2;        if(avg>=90&&avg<=100)        System.out.println("A grade");        else if(avg>=80&&avg<=89)        System.out.println("B grade");        else if(avg>=70&&avg<=79)        System.out.println("C grade");        else if(avg>=60&&avg<=69)        System.out.println("D grade");        else if(avg>=50&&avg<=59)        System.out.println("E grade");        else if(avg>=40&&avg<=49)        System.out.println("F grade");        else        System.out.println("G grade");    }}


public class pg18_7{     public void main(int m)    {        if(m>=0&&m<=34)        System.out.println("FAIL");        else if(m>=35&&m<=59)        System.out.println("PASS");        else if(m>=60&&m<=79)        System.out.println("DISTINCTION");        else        System.out.println("EXCELLENT");    }}


public class pg18_8{     public void main(int a,int b,int c)   {       if(a>b&&a>c)       System.out.println("The greatest number among "+a+","+b+","+c+" is "+a);       else if(b>a&&b>c)       System.out.println("The greatest number among "+a+","+b+","+c+" is "+b);       else       System.out.println("The greatest number among "+a+","+b+","+c+" is "+c);    }}


public class pg19_9{    public void main(int a,int b,int ch)  {      int s=0,d,p=1,q;      switch(ch)      {          case 1: s=a+b;          System.out.println("The sum is "+s);          break;          case 2: if(a<b)          d=b-a;          else          d=a-b;          System.out.println("The difference is "+d);          break;          case 3: p=a*b;          System.out.println("The product is "+p);          break;          case 4: if(a<b)          q=b/a;          else          q=a/b;          System.out.println("The quotient is "+q);          break;          default:System.out.println("The given case number does not exist");        }  }}

public class pg20_10{    public void main(int ch)    {        switch(ch)        {            case 1: System.out.println("SUNDAY");            break;            case 2: System.out.println("MONDAY");            break;            case 3: System.out.println("TUESDAY");            break;            case 4: System.out.println("WEDNESDAY");            break;            case 5: System.out.println("THURSDAY");            break;            case 6: System.out.println("FRIDAY");            break;            case 7: System.out.println("SATURDAY");            break;            default: System.out.println("wrong input");        }    }  }
Similar questions