Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cmath>
- using namespace std;
- int main(){
- int numberFishes;
- cin >> numberFishes;
- string input;
- cin.ignore();
- getline(cin, input);
- int digit = 0;
- int counterFishes = 0;
- int counter = 0;
- double moneyOwned = 0;
- double moneySpend = 0;
- while (input != "Stop" && counterFishes <= numberFishes){
- double kgFish;
- cin >> kgFish;
- counterFishes ++;
- counter ++;
- cout.setf(ios::fixed);
- cout.precision(2);
- for (int i = 0; i < input.size(); i++){
- digit += input [i];
- }
- if (counter < 3){
- moneySpend += digit / kgFish * 1.0;
- digit = 0;
- } else {
- moneyOwned += digit / kgFish * 1.0;
- digit = 0;
- counter = 0;
- }
- if (counterFishes == numberFishes){
- break;
- } else {
- cin.ignore();
- getline(cin, input);
- }
- }
- if (counterFishes == numberFishes){
- cout << "Lyubo fulfilled the quota!" << endl;
- }
- if (moneyOwned >= moneySpend){
- cout << "Lyubo's profit from " << counterFishes << " fishes is " << moneyOwned - moneySpend << " leva." << endl;
- } else {
- cout << "Lyubo lost " << moneySpend - moneyOwned << " leva today." << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement