I am currently taking a C++ program at my college and it all just seems foreign to me. I am having some trouble with this problem..

The Yukon Widget Company manufactures widgets that weigh 9.2 pounds each. Write a program that calculates how many widgets are stacked on a pallet, based on the total weight of the pallet. The program should ask the user how much the pallet weights by itself and with the widgets stacked on it. It should then calculate and display the number of widges stacked on the pallet.

If someone would help me it would be greatly appreciated!

It's an easy problem, just remember to split it up into parts.


>The program should ask the user how much the pallet weights by itself
First, make a program.

#include <iostream>

int main() {
}

Now, allow the user to input the weight of the pallet.

#include <iostream>

int main() {
  float palletWeight;
  std::cout << "Enter pallet weight: ";
  std::cin >> palletWeight;
}

There, that's one step done.

Now, try the next step. The same as I have just shown you. But this time..."with the widgets stacked on it". Make another variable with the type float, perhaps called totalWeight, then allow the user to input the total weight using std::cin.

Hope this helps.

Once you have both of those, you can use the two numbers to calculate the total weight of the widgets.

And if you know how much all the widgets weigh and how much a single widget weighs (and at this point you would know both of those) you can calculate how many widgets must be on the pallet.

Thank you so much!!! im just starting this and its an online course.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.