4. Nested Logic


We just have to add some of the else if statements so that there are more conditions for other age groups-
if(age<=3)
cout<<"children under 3 can enjoy free tickets. "<<endl;
else if(age>=4 && age<=12){
cout<<"your ticket price is $20. "<<endl;
else if(age>=65)
cout<<"your ticket price is $30. "<<endl;
else{
cout<<"your ticket price is $50. "<<endl;
Program-
#include <iostream> using namespace std; int main() cout << "children under 3 can enjoy free tickets."<<endl;} else if(age>=4 && age<=12){ cout << "your ticket price is $20."<<endl;} else if(age>=65){ cout << "your ticket price is $30."<<endl;} else{ cout << "your ticket price is $50."<<endl;} return 0; |
Step by step
Solved in 5 steps with 11 images









