Skip to content

Instantly share code, notes, and snippets.

@kshitijvarshne1
Created July 17, 2020 05:08
Show Gist options
  • Save kshitijvarshne1/d7256154b9da14de97a1a8f6b350595e to your computer and use it in GitHub Desktop.
Save kshitijvarshne1/d7256154b9da14de97a1a8f6b350595e to your computer and use it in GitHub Desktop.
Enter a no from 0 to 100
/*
NAME-Kshitij
DATE-13th july 2020
TIME-01:27 PM
*/
import java.util.Scanner;
public class p1 {
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
System.out.println("Enter a no from 0 to 100 :-");
int number=sc.nextInt();
if (number==0)
{
System.out.println("Zero");
}
else if (number == 100)
{
System.out.println("Hundred");
}
else if (number>0 & number <10)
{
if (number ==1 )
{
System.out.println("One");
}
else if (number==2){
System.out.println("Two");
}
else if (number==3){
System.out.println("Three");
}
else if(number==4){
System.out.println("Four");
}
else if(number==5){
System.out.println("Five");
}
else if(number==6){
System.out.println("Six");
}
else if(number==7){
System.out.println("Seven");
}
else if(number==8){
System.out.println("Eight");
}
else if (number==9){
System.out.println("Nine");
}
}
else if (number>10 & number <20)
{
if (number ==11 )
{
System.out.println("Eleven");
}
else if (number==12){
System.out.println("Twelve");
}
else if (number==13){
System.out.println("Thirteen");
}
else if(number==14){
System.out.println("Fourteen");
}
else if(number==15){
System.out.println("Fifteen");
}
else if(number==16){
System.out.println("Sixteen");
}
else if(number==17){
System.out.println("Seventeen");
}
else if(number==18){
System.out.println("Eighteen");
}
else if (number==19){
System.out.println("Ninteen");
}
}
// now code for the number which is two digit no
// count =2
int rem,first_no;
rem=number%10;
number=number/10;
if (rem==0){
if (number ==1 )
{
System.out.println("Ten");
}
else if (number ==2 )
{
System.out.println("twenty");
}
else if (number==3){
System.out.println("Thirty");
}
else if(number==4){
System.out.println("Fourty");
}
else if(number==5){
System.out.println("Fifty");
}
else if(number==6){
System.out.println("Sixty");
}
else if(number==7){
System.out.println("Seventy");
}
else if(number==8){
System.out.println("Eighty");
}
else if (number==9){
System.out.println("Ninty");
}
}
else
{ if(number==2){
System.out.print("Twenty");
}
else if (number==3){
System.out.print("Thirty");
}
else if(number==4){
System.out.print("Fourty");
}
else if(number==5){
System.out.print("Fifty");
}
else if(number==6){
System.out.print("Sixty");
}
else if(number==7){
System.out.print("Seventy");
}
else if(number==8){
System.out.print("Eighty");
}
else if (number==9){
System.out.print("Ninty");
}
if (rem>0 & rem<10)
{
if (rem ==1 )
{
System.out.println("- One");
}
else if (rem ==2){
System.out.println(" - Two");
}
else if (rem ==3){
System.out.println(" - Three");
}
else if(rem ==4){
System.out.println(" - Four");
}
else if(rem ==5){
System.out.println(" - Five");
}
else if(rem ==6){
System.out.println(" - Six");
}
else if(rem ==7){
System.out.println(" - Seven");
}
else if(rem ==8){
System.out.println(" - Eight");
}
else if (rem ==9){
System.out.println(" - Nine");
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment