The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

C++ HELP!

View previous topic View next topic Go down

C++ HELP!

Post by magicm00n on March 1st 2012, 3:18 pm

Hi i want to add this code to my C++ forum that helps users calculate the weights needed to balance.

This is the question:
A balance has the following size weights: 100 lb, 50 lb, 10 lb, 5 lb, and 1 lb. The number of 100 lb and 50 lb weights required to weigh an object weighing weight pounds can be calculated by using the following C++ statements:
// Determine the number of 100 lb weights
w100 = int(weight/100)
// Determine the number of 50 lb weights
w50 = int((weight w100 * 100)/50)

Using these statements as a starting point, how to write a code that accepts a weight input from the user and then calculates the number of each type of weight needed to weigh that object.

this is what i got so far and i am lost:
Code:

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
   int weight, w100, w50, w20, w10, w5, w1;

   cout<<"Please enter a weight: ";
   cin>>weight;
   cout<<"The number of weights needed to balance are "<<w100<<w50<<w20<<w10<<w5<<w1<<endl;

   w100 = int(weight/100);
   w50 = int((weight - w100 * 100)/50);
   w20 = int((weight - w100 * 100)/20);
   w10 = int((weight - w100 * 100)/10);
   w5 = int((weight - w100 * 100)/5);
   w1 = int((weight - w100 * 100)/1);

return 0;
}

What am I doing wrong?? I am new to c++! help pls

magicm00n
Active Poster

Female Posts : 1305
Reputation : 217
Language : English
Location : The support forum of Forumotion

Back to top Go down

Re: C++ HELP!

Post by LGforum on March 1st 2012, 3:23 pm

C++ is not a web language. Therefore not in anyway related to forums.
For something like what you are saying on the internet, you'd need to use Javascript. Javascript is similar to C++ in quite a few ways, the same IF,ELSE,FOR,WHILE structures.

LGforum
Hyperactive

Male Posts : 2254
Reputation : 254
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Re: C++ HELP!

Post by Sanket on March 1st 2012, 3:24 pm

Sorry, only questions related to Forumotion are allowed.

Please google for C++ help forums.

Thread Garbaged.

Sanket
ForumGuru

Male Posts : 48766
Reputation : 2819
Language : English
Location : Mumbai

http://webartzforum.com

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum