0

var actualprice=(100)-(100*20/100); console.log("Total amount is : " +actualprice)

Why is this above given answer in question not working as of big sale project question in java script?

2nd Jun 2021, 9:25 AM
BEHCET AYTIMUR AHISKA
BEHCET AYTIMUR AHISKA - avatar
7 Respuestas
+ 1
BEHCET AYTIMUR AHISKA Because you have taken hard code value 100 you have to take it from user because there maybe many test case with different input value.
2nd Jun 2021, 9:48 AM
A͢J
A͢J - avatar
+ 1
BEHCET AYTIMUR AHISKA Why did you use print (value)? Doesn't make sense because it's not Python. Here is the simple solution: function main() { var oldPrice = parseInt(readLine(), 10) // your code goes here console.log(oldPrice - 20 * oldPrice / 100); }
3rd Jun 2021, 11:13 AM
A͢J
A͢J - avatar
0
var totalprice=prompt("Enter rhe total price of the product"); var discount=prompt("Enter the discount percent on that product"); var actualprice=(totalprice*discount)/100; console.log("Total amount is : " +actualprice); l wonder the one that l have considered work properly?
2nd Jun 2021, 10:16 AM
BEHCET AYTIMUR AHISKA
BEHCET AYTIMUR AHISKA - avatar
0
var totalprice=prompt("Enter rhe total price of the product"); var discount=prompt("Enter the discount percent on that product"); var actualprice=(totalprice*discount)/100; console.log("Total amount is : " +actualprice); l wonder if the one that l have considered above, may it work unbugged properly?
2nd Jun 2021, 10:21 AM
BEHCET AYTIMUR AHISKA
BEHCET AYTIMUR AHISKA - avatar
0
BEHCET AYTIMUR AHISKA we use prompt when user enter input but here inputs are already given so use readLine. I said user input it doens't mean that you have to use prompt. See the test cases input are already given. User will not enter value here. So you have to use this command to take input: var oldPrice = parseInt(readLine(), 10); console.log(oldPrice - 20 * oldPrice / 100);
2nd Jun 2021, 1:32 PM
A͢J
A͢J - avatar
0
BEHCET AYTIMUR AHISKA You just have to print only value. So don't print anything else.
2nd Jun 2021, 1:32 PM
A͢J
A͢J - avatar
0
AJANANT thanks to your attention to my query and the problem remained unanswered still in my hand as the bugs very simple in it but not found yet: var oldPrice=parselnt(readline(), 10); console.log(oldPrice -20 * oldPrice / 100); print(value); this code bit has bugs still in response to the question of discounted value asked. parselnt is not defined in module in the project before and no need it in it to run given as answered. question quoted Time to go shopping! Everything in the store has been discounted by 20%. You are given a program that takes the price of an item as input. Complete the program so that it outputs the discounted price to the console. Sample Input 100 Sample Output 80 Explanation 20 percent of 100 equals to 20 (100 * 20/100), so the discounted price will be 80 (100 - 20). unquoted
3rd Jun 2021, 9:20 AM
BEHCET AYTIMUR AHISKA
BEHCET AYTIMUR AHISKA - avatar