Categories

CODE
Visual C++ Programming
C++ (Non Visual C++ Issues)
Modern Windows Apps (Metro)
C++ and WinAPI
Managed C++ and C++/CLI
Visual C++ Bugs & Fixes
Graphics Programming
Multithreading
Network Programming
Driver Development
Visual Basic 6.0 Programming
Visual Basic .NET
Crystal Reports
C-Sharp Programming
Managed C++
Visual Basic .NET
ASP.NET
.NET Framework
ADO.NET
Windows Presentation Foundation (WPF) & XAML forum
Silverlight
.NET Installation and Configuration Issues
Java Programming
AJAX
Scripting - Client Side
Database
XML
Wireless/Mobile Development
Assembly
Scripting - Server Side (PHP, Perl, etc.)
Python
General Developer Topics
Project Planning, Design, and Management
Testers and Testing
Algorithms & Data Structures
General Discussion / Chit Chat
Announcements, Press Releases, & News
Feedback
Articles Suggestions
Testing Area
Programming Projects
C# Game(s) Project
Game Engine Project
C++ Coding Project
Project: Code War
Slow Chat: Talk with Microsoft Developer Teams
Slow Chat: Developing Multithreaded Applications
Slow Chat: C++0x
Slow Chat: Visual C++: Yesterday, Today, and Tomorrow
Directory Services
General Windows and DNA Programming
Windows OS Issues
Open Positions (Jobs)
Looking for Work
Visual Basic .NET FAQs
Visual Basic FAQs
CodeGuru Individual FAQs
CodeGuru Individual Visual Basic FAQs

Resources

Java Database
Linux
Coding
Mobile
Hardware
Software Development
Software Development
iOS,OS X
iOS,OS X
ORACLE
IBM DEVELOPER
IBM DEVELOPER
MSDN
MSDN


Tags

Visual C++ Programming

Ask questions about Windows programming with Visual C++ and help others by answering their questions.

Help me code this problem in c c++ or java


A program to solve the following problem.  You can use C, C++, C#, Java or Haskell to code your solution.    The problem  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 currencyTCS Ignite Open Lab  4    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:  scanf(%d %d %d, &principal, &rate, &years);  printf(%8.2f\n, principalrateyears/100.0);  				  			

  				  					So, what have you already done and what difficulty do you have with?  				  			

  				  					click  				  			

  				  					  	  		  			  			  				  					 Originally Posted by 123starweb  					  				  				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.  			  		  	   This problem is a basic recursion - if you know how recursion works (and think a bit ) you should be able to solve it.    But, a bit of advice - if you do this in C/C++ or Java you will need to be very careful about what data type you use to represent your mass/currency in order to avoid overflow errors.    Haskell doesn't have this issue though, so if you know Haskell you won't have to worry about overflow.


Related Links

Strings from the registry
Locking Folder
CDaoDatabase problem??
Bug in C++ 6.0 SP6?
Function Name Mangling in MSVC
return of CWinApp::InitInstance()
Returning a Array From ActiveX Control
Transparent icons on office-toolbars
Add items to a grid in VC++
How to Display Images
Error 183 on opening an file using CFile
A Simple Question
Setting background color in listcontrol?
use of sc create
CDaoDatabase
How can I update the content of CEdit in a cycles