+ 2
What’s wrong with this??
20 Respuestas
+ 3
First u need to take user input i.e. Price of the item.
Then u need to perform a small calculation price-=20/100*price
Then output the discounted price.
Hope u understand the Question and algorithm.
+ 3
Isabel Thompson First you need to create a variable and assign an input to it. You can make the input expect by changing it to parseInt(readLine(), 10)
Hope you know how to find the discount.
Define the discount as a variable and use console.log() to get the output.
By the way, I gave some hints. Try to finish it yourself. Show your try if you can't solve it.
+ 3
//try this
function main() {
var inp = parseInt(readLine(), 10);
var total = 80/100 *inp;
console.log(total )
}
+ 3
Here is one of the ways to put it:
function main() {
var oldPrice = parseInt(readLine(), 10)
var discount = oldPrice*20/100
console.log (oldPrice-discount)
}
+ 2
What's wrong in this Question??
+ 1
Isabel Thompson , it's easy. As a hint read the input like an int type. Perform the calculation - 20% discount means => new price is 80% * old price. Output the result.
+ 1
Hi guys, thank you all for the help. I stil dont get it.
var inp = 20/100*100;
var total = 100 - inp;
console.log(total);
still wrong! what am I doing wrong??
0
yes, how can I do it?
0
Time to go shopping!
Everything in a store has been discounted by 20%.
You’re given a program that takes the price of an item as input. Complete the program so that it’ll output the discounted price to the console.
Sample Input
100
Sample Output
80
0
i dont know how to do it. Can someone explain??
0
Hey it can be done using getter and setter method
Can you give me code bcoz this link is only for PRO
0
It is same like this code
Just u need to do some changes
https://code.sololearn.com/c5sKe25X695x/?ref=app
If you not understand give me full code not link , So can i understad u.
0
Guy, I’m trying to solve it in JavaScrip... still not working.
0
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
0
//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
const discount = oldPrice * 20/100;
const newPrice = oldPrice - discount;
console.log(newPrice);
}
0
//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
var discount = (20/100*oldPrice);
var total = oldPrice -discount ;
console.log(total) ;
}
- 2
would like to practice for beginners