Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int main()
  5. {
  6. char name[20];
  7. float height = 0;
  8. float width = 0;
  9. float length = 0;
  10. float paint = 0;
  11.  
  12. // Ask the user for their name
  13. cout << "Hello user, please enter your first name: ";
  14. cin >> name;
  15. cout << "I got " << name << "." << endl;
  16.  
  17. // Ask user for the deminsions
  18. do
  19. {
  20. cout << "Okay " << name << ", please enter the length of the house:";
  21. cin >> length;
  22. if (length < 0)
  23. cout << "That input is invalid. Please enter a positive number, " << name << ".";
  24. } while (length < 0);
  25.  
  26. do
  27. {
  28. cout << "I got the lenth " << name << ", now enter the width of the house: ";
  29. cin >> width;
  30. if (width < 0)
  31. cout << "That input is invalid. Please enter a positive number, " << name << ".";
  32. } while (width < 0);
  33.  
  34. do
  35. {
  36. cout << "I got the width, now enter the height of the house, " << name << ":";
  37. cin >> height;
  38. if (height < 0)
  39. cout << "That input is invalid. Please enter a positive number, " << name << ".";
  40. } while (height < 0);
  41.  
  42. do
  43. {
  44. cout << "Lastly, " << name << ", please enter the amount of coats youd like to apply on the house:";
  45. cin >> paint;
  46. if (paint < 0)
  47. cout << "That input is invalid. Please enter a positive number, " << name << ".";
  48. } while (paint < 0);
  49.  
  50.  
  51. system("pause");
  52. return 0;
  53.  
  54.  
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement