Given the string "Expense is 1000 rs", extract the number 1000, add 100 to it, and print the result as "Expense is 1100".

AnswerBot
1y
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
11mo
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
1y
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 & answers
An Associate Software Engineer was asked Q. What is Spring Boot?
An Associate Software Engineer was asked Q. Why is a string immutable?
An Associate Software Engineer was asked Q. What is hoisting?
Popular interview questions of Associate Software Engineer
An Associate Software Engineer was asked Q1. What is Spring Boot?
An Associate Software Engineer was asked Q2. Why is a string immutable?
An Associate Software Engineer was asked Q3. What is hoisting?
>
Test Yantra Software Solutions Associate Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

