Answer to Question #39680 in C++ for Jeff

Question #39680
I need an algorithm to be able to calculate cost when there is a sale for buy two get one free
1
Expert's answer
2014-03-13T13:43:40-0400
#include <iostream>
#include <cmath>


using namespace std;


int main()
{
int n = 0;
cout <<"Enter number of items please:
";
cin >> n;
double total = 0, temp = 0;
for (int i = 1; i <= n; ++i)
{
cout << "Enter price of item number " << i << ":
";
cin >> temp;
if (i % 3)
total += temp;
}

cout << "Total price: " << total;
cin.get(); cin.get();
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS