Question

Need help with creating conversion function

checkout (num_hats, num_tels, num_creams): This function starts off knowing how many Headless Hats, Boxing Telescopes, and Canary Creams we would like to purchase at Weasleys Wizard Wheezes. You can just use those three parameters to calculate. (Assume theyre all non-negative numbers). The prices are two galleons per Headless Hat, 12 sickles and 26 knuts per Boxing Telescope, and seven sickles per Canary Cream. Calculate and return the total price in knuts. In the wizarding world, a galleon is worth 17 sickles, and one sickle is worth 29 knuts. o assume all three parameters (num hats, num_tels, num_creams) are non-negative integers. checkout(e, e, 1) checkout(0, 1, e)-* checkout(e, 2, e) checkout(1, 1, 1)> 15 203 374 748 63

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//function in C++

#include <iostream>

using namespace std;

int checkout (int ,int ,int);

int main(){

cout <<"checkout (0, 0, 1) -> "<<checkout (0, 0, 1)<<"\n";

cout <<"checkout (0, 1, 0) -> "<<checkout (0, 1, 0)<<"\n";

cout <<"checkout (0, 2, 0) -> "<<checkout (0, 2, 0)<<"\n";

cout <<"checkout (1, 1, 1) -> "<<checkout (1, 1, 1)<<"\n";

return 0;

}

int checkout (int num_hats, int num_tels, int num_creams){

int sickle =29;

int galleons =17 * sickle;

int price = num_hats * 2* galleons + num_tels *(12*sickle +26) +num_creams * 7 *sickle;

return price;

}

//sample output

C:\Users IshuManish\ Documents price.exe heckout <0. 0. 1- 203 heckout <1. 1.1> 1563 Process exited after Press any key to continue 9.2852 seconds with eturn value 0 -

Add a comment
Know the answer?
Add Answer to:
Need help with creating conversion function checkout (num_hats, num_tels, num_creams): This function starts off knowing how...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT