Page 1 of 1

String Challenge Have the function String Challenge (strArr) take the strArr parameter being passed, which will only con

Posted: Tue Jul 12, 2022 8:05 am
by answerhappygod
String Challenge Have The Function String Challenge Strarr Take The Strarr Parameter Being Passed Which Will Only Con 1
String Challenge Have The Function String Challenge Strarr Take The Strarr Parameter Being Passed Which Will Only Con 1 (65.72 KiB) Viewed 113 times
String Challenge Have the function String Challenge (strArr) take the strArr parameter being passed, which will only contain a single element, and return the string true if it is a valid number that contains only digits with properly placed decimals and commas, otherwise return the string false. For example: if strArr is ["1,093,222.04"] then your program should return the string true, but if the input were ["1,093,22.04"] then your program should return the string false. The input may contain characters other than digits. Examples Input: new String[] {"0.232567"} Output: true Input: new String[] {"2,567.00.2"} Output: false
import java.util.*; import java.io.*; class Main { } public static String StringChallenge (String[] strArr) { // code goes here return strArr [0]; } public static void main (String[] args) { // keep this function call here Scanner s = new Scanner(System.in); System.out.print(String Challenge (s.nextLine())); }