In this article I would like to share with you a very simple program to ask the user to give a string which contains a numbers or digits and then our program will remove the digits or numbers in the given string by our user using Java as our programming language.
I am currently accepting programming work kindly contact me in the following email address for further details. Thank you.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Sample Program Output
Program Listing
Remove_Digits.java
/**
*
*/
package remove_digits;
import java.util.Scanner;
/**
* @author Jake R. Pomperada
* Bacolod City, Negros Occidental, Philippines
* September 29, 2017 Friday 7:22 PM
*/
public class Remove_Digits {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
String str_one, str_two;
System.out.print("\n\n");
System.out.print("===== Remove Digits in Java ====");
System.out.print("\n\n");
System.out.print("===== Written By: Mr. Jake R. Pomperada =====");;
System.out.print("\n\n");
System.out.print("Enter a String : ");
str_one = input.nextLine();
System.out.print("\n\n");
str_two = str_one.replaceAll("[1234567890]", "");
System.out.print("Original String :=> " + str_one + ".");
System.out.print("\n\n");
System.out.print("New String :=> " + str_two + ".");
System.out.print("\n\n");
System.out.println("END OF PROGRAM");
System.out.println();
input.close();
}
}
No comments:
Post a Comment