Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication1;
- /**
- *
- * @author Sharif
- */
- public class spelltest {
- public static void main(String[] args) {
- int val=20;
- int tenth=val%10;
- int oneth=val/10;
- if(val==0)
- System.out.println("zero");
- if(val<100)
- {
- if(val>=1 && val<=10)
- {
- spell(val);
- System.out.println();
- }
- else if(val>10 && val<=19)
- {
- if(val==11)
- System.out.println("eleven");
- else if(val==12)
- System.out.println("twelve");
- else if(val==13)
- System.out.println("thirteen");
- else if(val==14)
- System.out.println("fourteen");
- else if(val==15)
- System.out.println("fifteen");
- else if(val>15 && val<=19)
- {
- spell(tenth);
- System.out.println("teen");
- }
- }
- else if(val>=20 && val<=99)
- {
- if(oneth==2)
- System.out.print("twenty ");
- else if(oneth==3)
- System.out.print("thirty ");
- else if(oneth==4)
- System.out.print("forty ");
- else if(oneth==5)
- System.out.print("fifty ");
- else if(oneth==6)
- System.out.print("sixty ");
- else if(oneth==7)
- System.out.print("seventy ");
- else if(oneth==8)
- System.out .print("eighty ");
- else if(oneth==9)
- System.out .print("ninety ");
- spell(tenth);
- System.out.println();
- }
- }
- else{
- System.out.println("you have to give the value of val bellow 100");
- }
- }
- static void spell(int num)
- {
- if(num==1)
- System.out .print("one");
- else if(num==2)
- System.out .print("two");
- else if(num==3)
- System.out .print("three");
- else if(num==4)
- System.out .print("four");
- else if(num==5)
- System.out .print("five");
- else if(num==6)
- System.out .print("six");
- else if(num==7)
- System.out .print("seven");
- else if(num==8)
- System.out .print("eight");
- else if(num==9)
- System.out .print("nine");
- else if(num==10)
- System.out.print("ten");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement