0

im stuck here😞

/*write a program to print the number of day, amount taken for the day, and the amount remaining at the end of the day. The output should terminated when 30 days have been printed or the amount remaining is less than 100 litters, whichever come first. For example, if W is 1000 and P is 10, The output should startas follows; Day         Amount Taken        Amount Remaining  1                100                                   900 2                90                                    810 3                81                                     729 */ #include <iostream>  #include <iomanip>  using namespace std;  int main() {      int liter = 1000;      int amountTaken = 100;      int amountRemaining = liter - amountTaken ;      int = 5     int Day[i];      cout << "Please enter the number of liter : "; cin >> liter;     cout << "\n";      cout << fixed;      cout << setprecision (2);      cout << left << setw(15) << "Day;      cout << right << setw(15) amountRemaing cout<<"\n" return 0; }

13th Dec 2018, 1:13 PM
Notorious.mimi
Notorious.mimi - avatar
4 Réponses
+ 1
I think the only way to help you is writing you the code. Here is it. After that, please, complete the C++ tutorial on this page or someone similar, or buy and read _Thinking in C++_... #include <iostream> #include <iomanip> using namespace std; int main() { float liter; float percent; cout << "Please enter the number of liter: "; cin >> liter; cout << "Please enter the percentage taken: "; cin >> percent; cout << left << setw(15) << "Day" << setw(15) << "Amt Taken" << setw(15) << "Amt Rem." << endl; cout << fixed << setprecision(0); for (int i = 1; i <= 30; ++i) { cout << setw(15) << i; float taken = liter * percent / 100; cout << setw(15) << taken; liter -= taken; cout << setw(15) << liter; cout << endl; } return 0; }
13th Dec 2018, 2:09 PM
Daniel Martínez Ruiz
Daniel Martínez Ruiz - avatar
0
You did not set a loop for the 30 days updating the liters... The code does not compile... No head printed...
13th Dec 2018, 1:26 PM
Daniel Martínez Ruiz
Daniel Martínez Ruiz - avatar
0
Can you revise it? I am only a beginner and trying hard to solve my project. :'(
13th Dec 2018, 1:53 PM
Notorious.mimi
Notorious.mimi - avatar
0
Thank you so much @Daniel you are insane :)
13th Dec 2018, 2:37 PM
Notorious.mimi
Notorious.mimi - avatar