C++ PROGRAMMING Weighing IN Trucks using an array?

Pablo

Member
Joined
May 26, 2008
Messages
104
Reaction score
0
Points
16
Hello i have to write a program that stores the maximum weight for each truck in array and then you ask the user for the truck number and the weight of the truck. It should then output if the truck exceeds the weight limit or does not.the program needs to ask 7 times before it finishes. I have already stored the numbers in the array and got the program to run 7 times but im not sure how to compare the value in the array using only one if else statement.Could u please help.
The code i have so far is:
#include<iostream>
#include<string>
#include<iomanip>

using namespace std;

int main()

{
int list[] = {50000,25000,20000,35000,40000,25000,30000};
int num, weight;
int i;
const int maxCategory = 7;
cout << "This program ask the user for the truck number \nand the weigh-in value for each truck in a fleet." << endl;
cout << endl;

cout <<"The weigh-in value is compared to the established "
<<"maximum weight limit \nA message is displayed to tell "
<<"the user whether the truck is within \nweight limits." << endl;
cout << endl;

for
(i = 0; i <= maxCategory; i++)
{

cout <<"Please enter the truck number and weight:";
cin >> num >> weight;

}

system ("pause");
return 0;
}
 
Back
Top