Advertisement
Guest User

Fishing boat

a guest
Aug 15th, 2019
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.02 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. int main () {
  8.  
  9.     double budget;
  10.     int fishers;
  11.     string season;
  12.  
  13.     cin >> budget >> season >> fishers;
  14.  
  15.     double finalPrice=0,currentPrice=0;
  16.     bool validation = ((budget>=1 && budget<=8000)
  17.      && (fishers>=4 && fishers<=18)) ;
  18.     bool validation2 = (season=="Spring" || season=="Summer" ||
  19.             season=="Autumn" || season=="Winter");
  20.  
  21.         if ((season=="Autumn" || season=="Summer")&& validation==1){
  22.             if (fishers>=4 && fishers<=6){
  23.                 currentPrice= 4200 *0.90;
  24.             } else if (fishers>=7 && fishers<=11){
  25.                 currentPrice= 4200 *0.85;
  26.             } else if (fishers>=12) {
  27.                 currentPrice= 4200 *0.75;
  28.             }
  29.         } else if (season=="Spring" && validation==1){
  30.             if (fishers>=4 && fishers<=6){
  31.                 currentPrice= 3000 *0.90;
  32.             } else if (fishers>=7 && fishers<=11){
  33.                 currentPrice= 3000 *0.85;
  34.             } else if (fishers>=12) {
  35.                 currentPrice= 3000 *0.75;
  36.             }
  37.         } else if (season=="Winter" && validation==1){
  38.             if (fishers>=4 && fishers<=6){
  39.                 currentPrice= 2600 *0.90;
  40.             } else if (fishers>=7 && fishers<=11){
  41.                 currentPrice= 2600 *0.85;
  42.             } else if (fishers>=12) {
  43.                 currentPrice= 2600 *0.75;
  44.             }
  45.         }
  46.  
  47.         if (fishers%2==0 && season!="Autumn"){
  48.             finalPrice=currentPrice*0.95;
  49.         }else {
  50.             finalPrice=currentPrice;
  51.         }
  52.  
  53.  
  54.         cout.setf(ios::fixed);
  55.         cout.precision(2);
  56.  
  57.         if (currentPrice>=0 && finalPrice>=0 && validation2==1){
  58.             if(budget>=finalPrice){
  59.                     cout << "Yes! You have "<<budget-finalPrice<<" leva left." << endl;
  60.             } else if (budget<finalPrice){
  61.                     cout << "Not enough money! You need "<<finalPrice-budget<<" leva."<< endl;
  62.             }
  63.         }
  64.  
  65. return 0 ;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement