# Homework: Balance Question

Page 1 of 1

## 2 Replies - 6519 Views - Last Post: 28 June 2009 - 07:00 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=112172&amp;s=061f41e54938b99495d718d15e929685&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 LeoTey

Reputation: 0
• Posts: 1
• Joined: 28-June 09

# Homework: Balance Question

Posted 28 June 2009 - 05:14 AM

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, write a C++ program that accepts a weight input from the user and then calculates the number of each type of weight needed to weigh that object.

Can somebody teach me to do this question.............

Is This A Good Question/Topic? 0

## Replies To: Homework: Balance Question

### #2 apw5020

Reputation: 78
• Posts: 666
• Joined: 26-March 09

## Re: Homework: Balance Question

Posted 28 June 2009 - 05:23 AM

[rules][/rules]

### #3 UG Cyber

Reputation: 32
• Posts: 562
• Joined: 24-July 08

## Re: Homework: Balance Question

Posted 28 June 2009 - 07:00 AM

Though i agree with the rules, i would like to see some code, i will still give you some logic advice.

Ok, so the user gives you the weight. What you want to do is find out how many 100lb, 50lb, 10lb, 5lb, 1lb weights it will take to make that weight.

This statement
```int w100 = int(weight/100);
```

Is just simply telling you how many 100lb weights it would take to get the weight by dividing the weight given by 100.
the 'int' to the right of the '=' is telling the program to only return a whole number.

that should give you enough information to complete this.