First of all, Happy new year!!!
import java.io.*;
public class Main {
public static void main(String[] args) {
int input = 0;
switch (input) {
case 1:
System.out.print("one ");
break;
case 2:
System.out.print("two ");
break;
case 3:
System.out.print("three ");
break;
case 4:
System.out.print("four ");
break;
case 5:
System.out.print("five ");
break;
case 6:
System.out.print("six ");
break;
case 7:
System.out.print("seven ");
break;
case 8:
System.out.print("eight ");
break;
case 9:
System.out.print("nine ");
break;
}
switch (input) {
case 11:
System.out.print(" eleven");
break;
case 12:
System.out.print(" twelve");
break;
case 13:
System.out.print(" thirteen");
break;
case 14:
System.out.print(" fourteen");
break;
case 15:
System.out.print(" fifteen");
break;
case 16:
System.out.print(" sixteen");
break;
case 17:
System.out.print(" seventeen");
break;
case 18:
System.out.print(" eighteen");
break;
case 19:
System.out.print(" nineteen");
break;
}
switch (input) {
case 1:
System.out.print(" ten ");
case 2:
System.out.print(" twenty ");
break;
case 3:
System.out.print(" thirty ");
break;
case 4:
System.out.print(" forty ");
break;
case 5:
System.out.print(" fifty ");
break;
case 6:
System.out.print(" sixty ");
break;
case 7:
System.out.print(" seventy ");
break;
case 8:
System.out.print(" eighty ");
break;
case 9:
System.out.print(" ninety ");
break;
}
switch (input) {
case 1:
System.out.print("one hundred ");
break;
case 2:
System.out.print("two hundred ");
break;
case 3:
System.out.print("three hundred ");
break;
case 4:
System.out.print("four hundred ");
break;
case 5:
System.out.print("five hundred ");
break;
case 6:
System.out.print("six hundred ");
break;
case 7:
System.out.print("seven hundred ");
break;
case 8:
System.out.print("eight hundred ");
break;
case 9:
System.out.print("nine hundred ");
break;
}
System.out.print("Enter a number between 0 and 999: ");
BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
String n = "";
int p = Integer.parseInt(n);
if (p > 99 && p < 1000) {
int h = p/100;
System.out.println(h);
int x = p % 100;
if (x > 10 && x < 20) {
System.out.println(x);
}
if (x > 0 && x < 100) {
int y = x / 10;
System.out.println(y);
int z = x % 10;
System.out.println(z);
}
}
if ( p > 19 && p < 100) {
int t = p / 10;
System.out.println(t);
int u = p % 10;
System.out.println(u);
}
if (p > 10 && p < 20) {
System.out.println(p);
}
if (p < 10) {
System.out.println(p);
}
}
}
Hi, I'm beginner learning programming .:$ The goal of this java program is to convert an integer ranging from 0-999 to its word equivalent, and it should ask the user if he/she still wants to enter a new number(I have no idea how can I make that possible ):icon_eek:
I'm not even sure of this codes are close enough to attain that goal.
Can you point out my errors? What should I change? Am I getting there?
Any help is appreciated.
Have a nice day!