Friday, February 26, 2021

 

3.WAP IN JAVA TO INPUT THREE NUMBERS AND COUNT HOW MANY OF THEM ARE EVEN .

 

import java.util.*;

class Prog

{

 public static void main(String args[ ])

 {

   Scanner ob=new Scanner(System.in);

  int x,y,z;

System.out.print(“Enter the numbers”);

x=ob.nextInt();

y=ob.nextInt();

z=ob.nextInt();

int count=0;

if((x%2)==0)

count+;

if((y%2)==0)

count+;

if((z%2)==0)

count+;

System.out.println(“Total Even numbers”+count);

}

}

 

 

2.WAP IN JAVA TO INPUT TWO  NUMBERS AND DISPLAY THE LARGEST NUMBER AMONG THEM, IF BOTH THE NUMBERS ARE EQUAL , THEN DISPLAY A SUITABLE MESSAGE.

 

import java.util.*;

class Prog

{

 public static void main(String args[ ])

 {

   Scanner ob=new Scanner(System.in);

  int x,y;

System.out.print(“Enter the numbers”);

x=ob.nextInt();

y=ob.nextInt();

if(x==y)

System.out.println(“both the numbers are equal”);

if(x>y)

  System.out.println(x+”is largest”);

else

 System.out.println(y+”is largest”);

}

}

 

1.WAP IN JAVA TO INPUT A NUMBER AND CHECK WHETHER THE NUMBER IS ODD POSITIVE OR NOT.

 

import java.util.*;

class Prog

{

 public static void main(String args[ ])

 {

   Scanner ob=new Scanner(System.in);

 int num;

System.out.print(“Enter the number”);

num=ob.nextInt();

if((num>0)&&((num%2)!=0)))

  System.out.println(num+”is Odd Positive”);

else

 System.out.println(num+”is not Odd Positive”);

}

}

Thursday, February 18, 2021

 3. WAP IN JAVA TO INPUT PURCHASE AMOUNT FROM THE USER AND CALCULATE DISCOUNT AMOUNT FROM ON THE BASIS OF THE FOLLOWING :


IF PURCHASED AMOUNT IS UPTO Rs. 500 , DISCOUNT IS 10%

IF PURCHASED AMOUNT IS >Rs. 500 , BUT LESS THAN Rs.1000,

DISCOUNT IS 20%


IF PURCHASED AMOUNT IS IS GREATER THEN Rs. 1000 ,

DISCOUNT IS 30%


DISPLAY NETAMOUNT SHOULD PAY BY THE CUSTOMER .




import java.util.*; //import java packages


class Prog //declare the class

{

public static void main(String args[ ]) // “main” method

{

Scanner ob=new Scanner(System.in);


double pamt,discount,netamt; //declare the variable


System.out.print(“Enter Purchased Amount”); //input the value

pamt=ob.nextDouble( ) ;


if(pamt<=500)

discount=pamt*(10/100);


if((pamt>500) && (pamt<1000))

discount=pamt*(20/100);

if(pamt>=1000)

discount=pamt*(30/100);


netamt=pamt-discount;

System.out.prinln(“Net Amount payable”+discount); //display Discount Amount

System.out.prinln(“Net Amount payable”+netamt); //display Net Amount


} //end of “main”

} //end of class

 2. WAP IN JAVA TO INPUT A NUMBER WHICH CONSIST OF THREE DIGITS , DISPLAY TOTAL NUMBER OF EVEN DIGITS FROM IT .



import java.util.*; //import java packages


class Prog //declare the class

{

public static void main(String args[ ]) // “main” method

{

Scanner ob=new Scanner(System.in);


int num; //declare the variable


System.out.print(“Enter the number”); //input the value

num=ob.nextInt( ) ;


int x1=num%10; //extract the digits


num=num/10 ;


int x2=num%10;


int x3=num/10;


int count=0;


if((x1%2)==0) //check for Even digits and Count

count++;


if((x2%2)==0)

count++;


if((x3%2)==0)

count++;

System.out.prinln(“Total Even digits :”+count); //display total number of digits


} //end of “main”


} //end of class


 1. WAP IN JAVA TO INPUT A NUMBER WHICH CONSIST OF TWO DIGITS AND DISPLAY AVERAGE OF THE DIGITS.


import java.util.*; //import java packages


class Prog //declare the class

{

public static void main(String args[ ]) // “main” method

{

Scanner ob=new Scanner(System.in);


int num; //declare the variable


System.out.print(“Enter the number”); //input the value

num=ob.nextInt( ) ;


int x1=num%10; //extract the digits


int x2=num/10 ;


double avg=(double)((double)(x1)+(double)(x2))/2; //calculate average


System.out.println(“Average of the digits :”+avg); //display the average


} //end of “main”


} //end of class


  3.WAP IN JAVA TO INPUT THREE NUMBERS AND COUNT HOW MANY OF THEM ARE EVEN .   import java.util.*; class Prog {   public static ...