Help parsing strings in java, regex can be used.
CODE IN JAVA:
import java.util.Scanner;
import java.io.*;
public class Conversion {
public static void main(String args[]){
Scanner sc=new
Scanner(System.in);
String phone;
System.out.print("Enter
a phone number:");
phone=sc.nextLine();
StringBuilder str1=new
StringBuilder(phone);
int len,i,count=0;
len=str1.length();
for(i=len-1;i>=0;i--){
if(Character.isDigit(str1.charAt(i))){
count++;
if(count>4){
str1.setCharAt(i, '*');
}
}
}
System.out.println(str1);
}
}
OUTPUT:
Help parsing strings in java, regex can be used. Mask all the digits in a phone...
Supposing we are all celebrities who care about our privacy as much as our programming course grades....we hope our email address and cell phone number are masked if we type them online. Now you need to write a python/java code to realize this masking function. Requirement: (1) Assuming the input email address is in the format of "[email protected]", all names must be converted to lowercase and all letters between the first and last letter of the name1 must be replaced...
I need help with this assignment in C++, please! *** The instructions and programming style details are crucial for this assignment! Goal: Your assignment is to write a C+ program to read in a list of phone call records from a file, and output them in a more user-friendly format to the standard output (cout). In so doing, you will practice using the ifstream class, I'O manipulators, and the string class. File format: Here is an example of a file...
need help on C++ (User-Defined Function) Format all numerical decimal values with 4 digits after the decimal point. Process and sample run: a) Function 1: A void function that uses parameters passed by reference representing the name of a data file to read data from, amount of principal in an investment portfolio, interest rate (any number such as 5.5 for 5.5% interest rate, etc.) , number of times the interest is compounded, and the number of years the money is...
Assignment 6, Merge Arrays (java) Instructions In this assignment, you will write a program which merges two arrays of positive integers and removes any duplicate entries. Your program will first ask for a valid length which must be an integer which is 10 or greater. The program should continue to ask until a valid length is entered. The program will then create two arrays of the length entered, fill these with random integers between 1 and 100 inclusive, and print...
**TStack.py below** # CMPT 145: Linear ADTs # Defines the Stack ADT # # A stack (also called a pushdown or LIFO stack) is a compound # data structure in which the data values are ordered according # to the LIFO (last-in first-out) protocol. # # Implementation: # This implementation was designed to point out when ADT operations are # used incorrectly. def create(): """ Purpose creates an empty stack Return an empty stack """ return '__Stack__',list() def is_empty(stack): """...
i need help with a mips program to to covert roman numerals to real numbers Lab 4: Roman Numeral Conversion Part A: Due Sunday, 19 May 2019, 11:59 PM Due Friday, 24 May 2019, 11:59 PM Part B: Minimum Submission Requirements Ensure that your Lab4 folder contains the following files (note the capitalization convention): o Diagram.pdf o Lab4. asm O README.txt Commit and push your repository Lab Objective In this lab, you will develop a more detailed understanding of how...