#include <iostream>
using namespace std;
int main() {
int number;
double price = 1.5;
double total = 0;
cout << "Enter number of water bottles: ";
cin >> number;
for (int i = 0; i < number; ++i) {
total += price;
price -= 0.05;
}
cout << "Total price is: " << total << "$";
return 0;
}
Outputs:
Comments
Leave a comment