Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit138d00d

Browse files
add 2288
1 parent6264e84 commit138d00d

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|------|----------------|------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|-------------|-------------
11+
| 2288|[Apply Discount to Prices](https://leetcode.com/problems/apply-discount-to-prices/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2288.java)|| Medium||
1112
| 2284|[Sender With Largest Word Count](https://leetcode.com/problems/sender-with-largest-word-count/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2284.java)|| Medium||
1213
| 2283|[Check if Number Has Equal Digit Count and Digit Value](https://leetcode.com/problems/check-if-number-has-equal-digit-count-and-digit-value/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2283.java)|| Easy||
1314
| 2279|[Maximum Bags With Full Capacity of Rocks](https://leetcode.com/problems/maximum-bags-with-full-capacity-of-rocks/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2279.java)|| Medium||
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
packagecom.fishercoder.solutions;
2+
3+
publicclass_2288 {
4+
publicstaticclassSolution1 {
5+
publicStringdiscountPrices(Stringsentence,intdiscount) {
6+
StringBuildersb =newStringBuilder();
7+
String[]words =sentence.split(" ");
8+
for (Stringword :words) {
9+
if (word.charAt(0) =='$') {
10+
try {
11+
longnum =Long.parseLong(word.substring(1));
12+
doublenewNum =Math.round(num * (1 - ((discount *1.0) /100)) *100.00) /100.00;
13+
sb.append("$");
14+
sb.append(String.format("%.2f",newNum));
15+
}catch (Exceptione) {
16+
sb.append(word);
17+
}
18+
}else {
19+
sb.append(word);
20+
}
21+
sb.append(" ");
22+
}
23+
returnsb.substring(0,sb.length() -1);
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp