Strings and GUI Quiz Practice

  1. Describe one clear advantage of writing a GUI program rather
    than programming in text-mode.
      
  2. Explain how you can use a method(s) to make a program simpler.
      
  3. Outline the purpose of the actions method in an EasyApp program.
      
  4. Write a single command to input the price of a lunch.
    Assume you are using EasyApp.
      
  5. Write the correct .substring command so that the following prints "ates":
      String info = "Mr Gates is rich";
      String name = info.substring(____ , ____);
      output(name);
        
  6. Write a short set of commands that input a user's password,
    and then check whether the user typed "secret" (the correct password).
    It should print either "correct" or "wrong".
     
  7. Explain why the following is incorrect:
      if (name == "Bob")
      {  output("Hi, Fred"); }
       
  8. Write a method that asks the user to type in their nationality AND age.
    The method should print "You can drive"  in the following circumstances:
            USA  ,  over 15
            Germany , over 18
            Japan  ,  over 21
    Any other inputs cause the method to print "You CANNOT drive".

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:

(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

//--------------------------------------------------------------------

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.