String s="Expense is 1000 rs"..Extract 1000 from the above string and add 100 to it, print it like Expense is 1100

AnswerBot
6mo

Extract and manipulate numerical value from a string.

  • Use regular expressions to extract the numerical value from the string.

  • Convert the extracted value to an integer, add 100 to it, and then format it...read more

ramesh cs
5mo
String s="Expense is 1000 rs"; String [] arr = s.split(" "); int num = Integer.parseInt(arr[2]) + 100; s = s.replace(arr[2],String.valueOf(num)); System.out.println(s);
Ayanokoji
6mo
Via Python : str = "Expense is 1000 rs" print(f"Expense is {int(str[11:15])+100} rs")
Add answer anonymously...
Test Yantra Software Solutions Associate Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter