1
Answer

Write the program C/C++/C#

Guddu Gupta

Guddu Gupta

9y
384
1
You have a block of platinum that can be exchanged in your bank either for cash or for smaller blocks of platinum. If you exchange a block of m grams, you get three blocks of weight m/2, m/3 and m/4 grams each. You don't get any fractional part, as the division process rounds down the value. If you exchange the block of platinum for cash, you get m units of currency. You can do any number of exchanges for smaller blocks or currency.
Given the value of a block in grams as input, write a program that would print the largest possible currency value that you can receive as the output. Assume that the maximum value of a block that can be given as an input is 1,000,000,000 grams and the minimum value is 2 grams.
Sample input 1 12
Sample output 1 13
Explanation: You can change 12 into blocks of 12/2 = 6, 12/3 = 4 and 12/4 = 3, and then exchange these for 6 + 4 + 3 = 13 units of currency 3
Sample input 2 2
Sample output 2 2
Explanation: If you exchange 2 grams into smaller blocks, it gives 2/2 = 1, 2/3 = 0, 2/4 = 0, only 1 unit. Instead, you can directly exchange the block for 2 units of currency.
Please note that your program SHOULD NOT print any prompts (“Please type the value of the block”) nor any header /footer (“***Block Max Value***”) as part of its output.
For example, if you are asked to print out the simple interest correct to two decimal places for a user specified values of principal, rate of interest and number of years, then only the following statements should be there corresponding to reading the input and printing the output: 4
scanf(“%d %d %d”, &principal, &rate, &years); printf(“%8.2f\n”, principal*rate*years/100.0);

Answers (1)
Next Recommended Forum