Locating avenuesâ€™ addresses in mid-Manhattan is not easy; for example, the nearest cross street
to 866 3rd Avenue is 53rd Street, whereas the nearest cross street to 866 Second Avenue is 46st
Street. To locate approximately the nearest numbered cross street for a given avenue address, the
following procedure can be used:
Cancel the last digit of the address (First digit from the right), divide by 2, and add or subtract
the number given in the following table:
I cant understand this question so I Would really need your help... thank you in advance..
ok I did it and here is the code for anyone who wants to see it
 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172`` ``````#include #include #include using namespace std ; int main () { string response ; int x=0,y=0,z,address,number ; cout << "This program computes the nearest cross street in mid-Manhattan from the Avenue address. \n " ; cout << "Would you like to try it? (Y/N) \n " ; cin >> response ; while (response != "y" && response != "Y" && response != "n" && response != "N" ) // locks use up in loop if he keeps entering wrong response { cout << "Error not valid entry try again \n " ; cout << "Would you like to try it? (Y/N) \n " ; cin >> response ; } while (response == "Y" || response == "y" ) // if the response is still Y it will keep going until user enters N or n { cout << "Please enter the avenue address " ; cin >> address ; while (address <100 || address>=1000) { cout << "please enter an address between 100 and 1000 \n " ; // keeps user in a loop until he enters a correct address number cin >> address ; } cout << "Please enter the avenue number "; cin >> number ; switch (number) { case 1 : x=address ; // assign x to address and y to avenue number to use in calculations while keeping the vaule of address and avenue number saved y=number ; x=x/10 ; x=x/2 ; z=x+3 ; cout << "The nearest cross street to " <
> response ; break ; case 2 : x=address ; y=number ; x=x/10 ; x=x/2 ; z=x+3 ; cout << "The nearest cross street to " <
> response ; break ; case 3 : x=address ; y=number ; x=x/10 ; x=x/2 ; z=x+10 ; cout << "The nearest cross street to " <
> response ; break ; case 4 : x=address ; y=number ; x=x/10 ; x=x/2 ; z=x+8 ; cout << "The nearest cross street to " <
> response ; break ; case 5 : if (address>=100 && address <=200) { x=address ; y=number ; x=x/10 ; x=x/2 ; z=x+13 ; cout << "The nearest cross street to " <
> response ; break ; } else if (address>=201 && address <=400) { x=address ; y=number ; x=x/10 ; x=x/2 ; z=x+16 ; cout << "The nearest cross street to " <
> response ; break ; } else cout << "please enter an address between 100 and 400,would you try again? (y)(n) \n " ; cin>> response ; break ; case 6 : x=address ; y=number ; x=x/10 ; x=x/2 ; z=x-12 ; cout << "The nearest cross street to " <
> response ; break ; case 7 : x=address ; y=number ; x=x/10 ; x=x/2 ; z=x+12 ; cout << "The nearest cross street to " <
> response ; break ; case 8 : x=address ; y=number ; x=x/10 ; x=x/2 ; z=x+10 ; cout << "The nearest cross street to " <
> response ; break ; case 10 : x=address ; y=number ; x=x/10 ; x=x/2 ; z=x+14 ; cout << "The nearest cross street to " <
> response ; break ; default : cout << "Error avenue number, Would you like to try again? (y)(n) \n " ; // if use enters an avenue number more than 10 cin >> response ; // or less than 0 user will have choice of trying again break ; } } if (response == "N" || response == "n") // if user enters N or n then program will end cout << "Thank you for using.. we hope we fulfilled your needs" << endl ; return 0 ; }``````
Last edited on
Where is the question/exercise?
so for 866 you would do this?

drop last digit : 86
divide by 2: 43
add number in the table: 43 + x