0

7.2 Practice Big Sale SOS (Newbie - Be Nice please)

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 //so we don’t overwhelm you, we’ve hidden the code that executes the input function main() { var oldPrice = parseInt(readLine(), 10) //your code goes here } ^That is the problem and I am also stuck... I tried like this: function main(){ var oldPrice = parseInt(readLine(),10) var percentage= (oldPrice*20/100); var oldPrice=100; var newPrice =oldPrice - percentage; console.log(newPrice); ^It worked for 1 case but ask for at least 2 more dif input and outputs (that was not in the question and also has 2 more "secret" answers).So I wondered if there is a way to make this var oldPrice has different values, I tried to give different values after the console.log and tested if the value changed but broke the code hahaha So please 🆘

22nd Mar 2021, 7:54 PM
Rhaná Teixeira
2 odpowiedzi
+ 3
Remove the line; var oldPrice = 100;
22nd Mar 2021, 10:11 PM
ChaoticDawg
ChaoticDawg - avatar
0
Try percentage = oldPrice*20.0/100 :: 20/100 result 0.(int/int=int) edit: comment 3rd line var oldPrice=100
22nd Mar 2021, 8:00 PM
Jayakrishna 🇮🇳