Validation Loop

This will compile and run, but after I enter tickets sold the Prompt close without displaying income generated.

hello guys, this is what I'm working on.

Theater Seating Revenue with Input Validation
A dramatic theater has three seating sections, and it charges the following prices for tickets in each section: section A seats cost $20 each, section B seats cost $15 each, and section C seats cost $10 each. The theater has 300 seats in section A, 500 seats in section B, and 200 seats in section C. Design a program that asks for the number of tickets sold in each section and then displays the amount of income generated from ticket sales. The program should validate the numbers that are entered for each section.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  
#include <string>
#include <istream>


   #include <iostream>
#include <limits>
using namespace std;

int main(int argc, char* argv[])

{ 
  int seca,secb,secc; 
  do 
{ 
  printf("Enter the number of tickets sold in section A\n"); 
  scanf("%d",&seca); 
  if(seca>300) 
  printf("Invalid input"); 
} while(seca>300); 
  do 
{ 
  printf("Enter the number of tickets sold in section B\n"); 
  scanf("%d",&secb); 
  if(secb>500) 
  printf("Invalid input"); 
} while(secb>500);  
  do 
{ 
  printf("Enter the number of tickets sold in section C\n"); 
  scanf("%d",&secc); 
  if(secc>200) 
  printf("Invalid input"); 
} while(secc>200); 
int totincome=(seca*20)+(secb*15)+(secc*10); 
  printf("Total income generated from ticket sales=$%d",totincome); 
} 
Topic archived. No new replies allowed.