0

Hi,
I have this code for an array:

{
cout << "how many tins sold? " << (i+1) ;
cin >> tinssold;

cout << "how much is each tin?" << (i+1) ;
cin >> tinprice;
		
value=(tinssold*tinprice
cout <<"total value of tins is " <<value;
}

IF I WANTED TO PUT AN if STATEMENT BEFORE THE VALUE IS PROCESSED SAYING THAT BASICALLY IF MORE THAN 52 TINS ARE SOLD THEN THE VALUE OF EACH TIN IS DOUBLED, HOW WOULD I DO THIS, WHAT WOULD THE IF STATEMENT LOOK LIKE?

PLEASE HELP!

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Comatose
1

1) You shouldn't post in red. It doesn't alter our level of urgency, and actually annoys us. I know your reason was probably to distinguish between your code and your words, but see 3 for that.
2) Let's not post in all caps. Makes it seem like you are yelling at me, and that doesn't inspire me to be helpful.
3) Use Code Tags. when you post code, you can use them by typing (without the spaces between [ and ]):
[ code=c++ ]
// your code here
[ /code ]

Since I am fairly unsure about a number of things in your code (such as missing parenthesis, why you are adding 1 to i during your output, and whatever convinced you to use >>) however, if you are wanting to add a simple if statement, as in the one you mentioned above:

if (tinssold > 52) {
     tinprice *= 2; // multiply by two is doubled right?
}
Votes + Comments
Well said. It's still horrid even without the wax crayon colouring in.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.