Published using Google Docs
Methods 1 - The Restaurant
Updated automatically every 5 minutes

The Restaurant

Void Methods with Parameters

Important Reminder:

For this assignment, all functions are VOID functions. You should not be using the word return at all.

As you can no doubt tell, in his younger days Mr. Couprie was a big hit with the ladies.  This assignment is dedicated to the good old days when he would spend nights out with friends and would work his magic on the women he would meet.

Create a new Java file called Assign3_Restaurant.

The RUN Method

The exact run() method you must use is copied below.  You may NOT deviate from this set up except where it specifically gives you the option to do so.  Note that much of the code is commented out.  Get each method working (described further down) before uncommenting the next one.

class Assign3_Restaurant {

   public static void run() {

        double mainSubtotal;

        int numPeople;

        String firstName;

        String phoneNumber;

       System.out.println("Welcome to Cafe Couprie, what is your first name so that I may check your reservation?");

       firstName = Library.wordscan.nextLine();

        System.out.println("Thank you. What is your phone number?");

        phoneNumber = Library.wordscan.nextLine();

        System.out.println("And how many people are in your party?");

        numPeople = Library.numscan.nextInt();

        System.out.println("Thank you " + firstName + ". Please enjoy our meal." );

       

        System.out.println();

        System.out.println("I hope you enjoyed your meal?");

        System.out.println("What is the subtotal?");

        mainSubtotal = Library.numscan.nextDouble();

        //splitBill(mainSubtotal, numPeople);

        //sing(firstName)  //this was wrong in original version

       

        hitOn(firstName, phoneNumber);

        //int weight;        

        //System.out.println("Um, that’s your boyfriend/girlfriend!? How much does he/she weigh?");

        //weight = Library.numscan.nextInt();

        //apologize(weight);

    }//end run

//your methods go here.

}//end class

You will notice that there are 5 variables in main

Once you have copied in the main method, test that the scanners are working.  

Method 1: Split Bill

public static void splitBill(double amount, int numPeople){  }

        

Each person in your party owes $___

Method 2: Sing (aka Happy Birthday) 

public static void sing (String name){  }

        Happy Birthday to you. Happy Birthday to you.

Happy Birthday dear Jerry.

Happy Birthday to you.

Method 3: HitOn (Asking the waiter/waitress for a date)

public static void hitOn(String name, String phone){  }

        

Well hello there handsome (or insert your best pick up line here)

        My name is Bob and you should call me at 555-5555.

Method 4: Apologize

public static void apologize(int pounds){  }

Final 10% - Add a Tip Calculator

What percentage do you want to tip?

15

Your total tip is $30.  Each person owes $7.50 for the tip.

Hint for Apologize Method:

You only need 2 lines inside the function. One is a FOR loop. The other is a println that says Sorry.  

The trick is figuring out what the FOR loop needs to look like.


Teacher use only

//100% - Methods are properly declared and called.  Good coding throughout.

//Quality pick up line used

//95% - Methods are properly declared and called.  Minor lapses in good coding cost you full marks.

//90% - Methods are properly declared and called.  Multiple lapses in good coding cost you top marks.

//Quality pick up line used

//80% - Only three of four methods completed.  Good coding throughout.

//70% - Only three of four methods completed.  Multiple lapses in good coding cost you marks.

//Poor pick up line used. You better up your game or you will lead a lonely life.