#include <iostream>
#include <string>

//using namespace std;

int main() {

  int weight;
  std::cout << "What is your weight: ";
  std::cin >> weight;
  while (std::cin.fail() || weight < 0 || weight > 4000) {
    if (std::cin.fail()) {
      std::cin.clear();
      std::cin.ignore(1000, '\n');
    }
    std::cout << "You've input an incorrect weight - try again: " << std::endl;
    std::cin >> weight;
  }


  std::string name; 
  std::cout << "Gimme name: ";
  std::cin >> name; 
  bool properName = true;
  for (unsigned int i = 0; i < name.length(); i++) {
    //std::cout << name[i] << std::endl;
    if (name[i] != 'a' && name[i] != 'b' &&
	name[i] != 'c' && name[i] != 'd') {
      properName = false;
    }
  }

  if (properName == true) {
    std::cout << "Thank you for your name!" << std::endl;
  }
  if (properName == false) {
    std::cout << "Hey only a b c and d are allowed!" << std::endl;
  }
  
  std::cout << "You've given me the weight: " << weight << std::endl;
}

