Section A: 21 October 2015 3:00 To 5:00 PM: Class Notes by DR B P Sharma - 8800600025
Section A: 21 October 2015 3:00 To 5:00 PM: Class Notes by DR B P Sharma - 8800600025
in | 8800600025
System.out.println(str.toUpperCase());
WhatsApp 8800360849 | 2nd Floor, SE-387A, Shastri Nagar Petrol Pump, Ghaziabad | @drbpsharma
Class Notes by Dr B P Sharma | http://fb.com/bpsharma.in | http://bpsharma.in | 8800600025
}
}
Example
WAP to input a number and convert that number into binary,
octal and hexa decimal.
WhatsApp 8800360849 | 2nd Floor, SE-387A, Shastri Nagar Petrol Pump, Ghaziabad | @drbpsharma
Class Notes by Dr B P Sharma | http://fb.com/bpsharma.in | http://bpsharma.in | 8800600025
System.out.println(Integer.toBinaryString(num));
System.out.println(Integer.toOctalString(num));
System.out.println(Integer.toHexString(num));
}
}
WAP to input a character and check it to be alphabet, digit and
special character.
WhatsApp 8800360849 | 2nd Floor, SE-387A, Shastri Nagar Petrol Pump, Ghaziabad | @drbpsharma
Class Notes by Dr B P Sharma | http://fb.com/bpsharma.in | http://bpsharma.in | 8800600025
Solution in C
#include<ctype.h>
main()
{
char ch;
printf("Enter a charater : ");
ch=getchar();
if(isdigit(ch))
printf("%c is a digit",ch);
else if(isalpha(ch))
printf("%c is an alphabet",ch);
else
printf("%c is special character",ch);
getch();
}
WhatsApp 8800360849 | 2nd Floor, SE-387A, Shastri Nagar Petrol Pump, Ghaziabad | @drbpsharma
Class Notes by Dr B P Sharma | http://fb.com/bpsharma.in | http://bpsharma.in | 8800600025
Solution in Java
- First read a character using read() method of System.in
o int read() throws IOException
import java.io.IOException;
public class CheckCharacter
{
public static void main(String args[]) throws IOException
{
System.out.print("Enter a character : ");
char ch=(char)System.in.read();
if(Character.isDigit(ch))
System.out.printf("%c is a digit",ch);
else if(Character.isLetter(ch))
System.out.printf("%c is an alphabet", ch);
else
System.out.printf("%c is special character",ch);
}
}
WhatsApp 8800360849 | 2nd Floor, SE-387A, Shastri Nagar Petrol Pump, Ghaziabad | @drbpsharma
Class Notes by Dr B P Sharma | http://fb.com/bpsharma.in | http://bpsharma.in | 8800600025
WhatsApp 8800360849 | 2nd Floor, SE-387A, Shastri Nagar Petrol Pump, Ghaziabad | @drbpsharma
Class Notes by Dr B P Sharma | http://fb.com/bpsharma.in | http://bpsharma.in | 8800600025
WhatsApp 8800360849 | 2nd Floor, SE-387A, Shastri Nagar Petrol Pump, Ghaziabad | @drbpsharma