Purpose To create an application that randomly chooses who will get expedited ch
ID: 3694285 • Letter: P
Question
Purpose To create an application that randomly chooses who will get expedited check-in versus the full check-in screening procedure at the airport by pointing an arrow to the “right” or to the “left”. See : http://lawnewz.com/crazy/tsa-spent-lots-of-to-develop-app-that-points-left-or-right-yes-thats-all-it-does/ develop-app-that-points-left-or-right-yes-thats-all-it-does/) Requirements (http://lawnewz.com/crazy/tsa-spent-lots-of-to- 1. Give the user the option to have a random selection made or to exit the program. 2. Indicate the direction (right or left) for the user. 3. The programs must provide a history of the selections. Your are required to use an array to store all selections in the order they are made. (100 selections should be plenty) 4. Before exiting the program, print out: A listing of all of the selections that were made. The total number and percentage of “right” selections. The total number and percentage of “left” selections This assignment is worth 10 pts. Example: RandomDir.exe Deliverables A zip file containing the source file (source.cpp). The name of your zip file should be something like extra_yourname.zip. Submit the zip file though the online submission of this site.
Explanation / Answer
The following cpp program prompots the user to select right or left or to exit.. While exiting, prog prints the list of selected values.
#include<iostream.h>
class Selection
{
public :
int select[100];
void printselection(int);
}
main()
{
int choice;
Selection s;
for(int i=0;i<100;i++)
{
cout<<”Enter your choice:”;
cout<<”select 1 for left”;
cout<<”/nselect 2 for right”;
cout<<”/nSelect 3 for exit”;
switch(choice)
{
case 1 :
s.select[i]=choice;
break;
case 2 :
s.select[i]=choice;
break;
case 3 :
cout<<”exiting program”;
s.printselection(i);
exit();
}
}
}
void Selection :: printselection(int i)
{
for(int j=0;j<i;j++)
{
if(select[j]==1) cout<<”left”;
else (select[j]==2) cout<<”right”
else cout<<”Program exited”;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.