+ 5
Currency converter
Create a function called convert with two parameters the amount to convert and rate and return the resulting amount.The code to take the parameters as input and call the function which is already in the playground and create a function to make the code work. input =100 1.1 Output =110 Here’s my code /* *convert * *Takes amount rate then returns the resulting amount * *@param double amount * *@param double rate * *@return double amount */ function convert(amount,rate) { return(amount*rate); }
26 Réponses
+ 15
First start by creating main function that can take input from user i.e currency and rate.
function main() {
var amount = parseFloat(readLine(), 10);
var rate = parseFloat(readLine(), 10);
console.log(convert(amount, rate));
}
Then create a function called convert that takes two parameters that are amount and rate.
function convert(amount,rate){
let cvt = amount * rate;
//At last return amount * rate
return cvt;
}
Hope it helps.
Cheers!
+ 6
function convert(amount, rate){
return amount * rate
}
+ 3
function main() {
var amount = parseFloat(readLine(), 10);
var rate = parseFloat(readLine(), 10);
const convert= (amount, rate)=> amount * rate;
console.log(convert(amount, rate));
}
+ 3
// Passes all tests
function main() {
var amount = parseFloat(readLine(), 10);
var rate = parseFloat(readLine(), 10);
function convert(amout,rate){
var final=amout*rate;
return final;
}
console.log(convert(amount, rate));
}
+ 1
Hi Ddhruv i did like this can you please tell me where i did wrong.
function main() {
var amount = parseFloat(readLine(), 10);
var rate = parseFloat(readLine(), 10);
function convert (convert )
console.log(convert(amount, rate));
}
function convert (100,1.1)
let convert(amount*rate)
return convert .
}
+ 1
function main() {
var amount = parseFloat(readLine(), 10);
var rate = parseFloat(readLine(), 10);
console.log(convert(amount, rate));
}
function convert(amount, rate) {
return amount * rate;
}
var x = convert(100, 1.1);
its working
+ 1
You are making a currency converter app.
Create a function called convert, which takes two parameters: the amount to convert, and the rate, and returns the resulting amount.
The code to take the parameters as input and call the function is already present in the Playground.
Create the function to make the code work.
Solution:
//leave them as they are.
function main() {
var amount = parseFloat(readLine(), 10);
var rate = parseFloat(readLine(), 10);
console.log(convert(amount, rate));
}
//Date from the question:
//function called convert = done
//two parameters (amount, rate) = done
//return resulting amount = done
//input amount = prompt = done //no need
function convert(amount, rate) {
//prompt = ("insert amount"); //no need
//rate = (amount * 1.1); //no need
return amount * rate;
};
convert(100,1.1); //function is called with the input data from the user.
If you like the solution, give it a thumb up.
Thanks
+ 1
function main() {
var amount = parseFloat(readLine(), 10);
var rate = parseFloat(readLine(), 10);
const convert= (amount, rate)=> amount * rate;
console.log(convert(amount, rate));
}
0
.
0
this is my poor code
function main() {
var amount = parseFloat(readLine(), 10);
var rate = parseFloat(readLine(), 10);
console.log(convert(amount, rate));
}
function convert(amount, rate) {
return amount * rate;
}
var x = convert(100, 1.1);
0
Zahor Mohammed Aziz you code is not correct.
Curly braces are not correct, function is not properly written.
You can see the solution given by Dani Prasetyo it's nearly the same, that you are trying to do.
Hope it helps.
0
Thanks for the reply Ddhruv i already solved it.
0
Zahor Mohammed Aziz that's great 🤩
0
function main() {
var amount = parseFloat(readLine(), 10);
var rate = parseFloat(readLine(), 10);
function convert(amount , rate){
var p = amount*rate;
return p;
}
console.log(convert(amount, rate));
}
This the answer .
0
function main() {
var amount = parseFloat(readLine(), 10);
var rate = parseFloat(readLine(), 10);
console.log(amount * rate);
}
0
function convert(amt,rate){
Var result = amt*rate;
return result;
}
console.log(convert(100,1.1);
0
function main() {
var amount = parseFloat(readLine(), 10);
var rate = parseFloat(readLine(), 10);
const convert= (amount, rate)=> amount * rate;
console.log(convert(amount, rate));
}
0
function main() {
var amount = parseFloat(readLine(), 10);
var rate = parseFloat(readLine(), 10);
console.log(convert(amount, rate));
}
function convert(amount,rate){
let cvt = amount * rate;
//At last return amount * rate
return cvt;
}
Good Luck
0
function convert(amount,rate)
{
return(amount*rate);
}
0
function main() {
var amount = parseFloat(readLine(), 10);
var rate = parseFloat(readLine(), 10);
function convert(amount ,rate){
return amount*rate;
}
console.log(convert(amount, rate));
}