You may use any notes you wish, including web-sites, as well as using a computer.
You
may write all your answers on the test page.
(9) State exactly what the output commands below will display:
String info = "Magic tricks";
int size = info.length();
char letter = info.charAt(2);
String word = info.substring(6,9);
int p = info.indexOf("tricks");
output(word); ___________________________
output(size); ___________________________
output(letter); ___________________________
output(p); ___________________________
(10) The following commands should input an e-mail address,
and
then decide whether it "looks right" by checking that:
i.
there cannot be any blank spaces in the String
ii.
the character "@" must be in the String
Fill
in the blanks to make it work correctly
____________ email = input("Type your email address");
_____________ pos = email.indexOf(" ");
if ( ___________________ )
{ output("No good - blank spaces are not permitted."); }
____________ atsign = email.________________( _______________ ) ;
if ( ________________ )
{ output("No good - there must be an @ sign somewhere."); }
//--------------------------------------------------------------------
Now add more commands to check that there is a period (dot) somewhere in the email address AFTER the "@" sign. For example:
"joe@fis" is not okay
"joe.smith@fis" is
not okay
"Joe@fis.edu" is okay.
Continue your answer on the back of the page.