Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. void solution();
  4. void main(void)
  5. {
  6. solution();
  7. }
  8. void solution()
  9. {
  10. int w_num, b_num, f_num;
  11. printf("Enter number of windows: ");
  12. scanf_s("%d", &w_num);
  13. printf("Enter number of balconys: ");
  14. scanf_s("%d", &b_num);
  15. loop:
  16. printf("Enter floor number: ");
  17. scanf_s("%d", &f_num);
  18. if (f_num > 0) {
  19. unsigned int summary_cost = 0, b_cost = 0, w_cost = 0;
  20. double w_sq = 0, b_sq = 0;
  21. if (f_num == 1) {
  22. w_cost = w_num * 100;
  23. w_sq = 2.15 * 1.5 * w_num;
  24. b_cost = b_num * 150;
  25. b_sq = 0.7 * 2.15 * 150;
  26. summary_cost = w_cost + b_cost;
  27. }
  28. else {
  29. printf("Windows price with 15 percentage for every window & square: ");
  30. w_cost = static_cast<int>(w_num * 100 * 1.15);
  31. w_sq = 2.15 * 1.5 * w_num;
  32. b_cost = b_num * 150;
  33. b_sq = 0.7 * 2.15 * 150;
  34. summary_cost = w_cost + w_cost;
  35. }
  36. printf("Price for windows & square: ");
  37. printf("%d\t%6.3f\n", w_cost, w_sq);
  38. printf("Price for balconys & square: ");
  39. printf("%d\t%6.3f\n", b_cost, b_sq);
  40. printf("Cost in dollars: ");
  41. printf("%d", summary_cost);
  42. }
  43. else {
  44. printf("Wrong floor number: ");
  45. goto loop;
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement