I need to make a program that reads in information from a file and compare it as follows:
Bags with girth over 62 in. but no not more than 115 in incur a charge of $100/bag.
Any bag with girth over 115 in. cannot be checked.
so once i read the numbers iwant add them up to get the wedith. I dont know hwo ot asses the charge (see below for my code; ignor the for loop for now)
You need an if statement to compare. Something like this:
if(girth > 62 && girth < 115)
//add the charge per bag
The && is the logical and operator, meaning that both of the conditions must be true in order for the code inside the if to be executed.
the else if would come after that with the condition being that girth is greater than 115 and you would then print that the bag cannot be checked I assume (don't know the exact requirements).
What is your definition of 'girth'?
Presumably it is: g1= 2*(width+height) or g2= 2*(length+height)
i.e. circumference widthwise or lengthwise whichever is greater
girthMax (g1>g2?g1:g2)
Then do as jpeg suggests