ICS 111 How do you write a code segment which prompts the user to enter the pric
ID: 3856525 • Letter: I
Question
ICS 111 How do you write a code segment which prompts the user to enter the price of a tour and receives input from the user. A valid tour price is between $52.95 and $259.95, inclusive. Your program should continue to repeat until a valid tour price has been entered. If the user enters an invalid price, display a message describing why the input is invalid. You may assume that the user only enters a real number. The user will not enter any invalid characters. Although the use of constants to test the minimum and maximum price of a tour would be appropriate if this were part of a program?
Explanation / Answer
#include <iostream>
using namespace std;
int main()
{
int a,min=52.95,max=259.95;
cout<<"Enter tour price";
cin>>a;
if(a>=min && a<=max)
{
cout<<"Valid tour price";
cout<<" "<<a;
}
else
{
cout<<"Not valid tour price Enter again";
cout<<" "<<a;
int b=main();
}
return 0;
}