63 125
Assignments Done
99%
Successfully Done
In July 2018

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
Expert's answer
#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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions