Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objective: Create an interactive Java program that models a restaurant by asking the user to enter input, generates a random response, and demonstrates the student's

Objective: Create an interactive Java program that models a restaurant by asking the user to enter input, generates a random response, and demonstrates the student's understanding of handling exceptions.

Related SLOs:

    SLO #1: Use an appropriate programming environment to design, code, compile, run, and debug computer programs.
    SLO #3: Illustrate basic programming concepts such as program flow and syntax of a high-level general-purpose language and basic security practices.
    SLO #4: Demonstrate working with primitive data types, strings, and arrays.

Instructions:

    Using jGRASP, write a Java program named LastnameFirstname05.java, using your last name and your first name, that does the following:
        Asks the user for their name, then addresses the user and welcomes them to a restaurant.
            Use at least two String methods on their name throughout the program. You can do whatever you want, I'm just looking to see that you know how to use the String methods.
        Generates a random number to determine the restaurant's special dish for the day.
            Use a Math method to generate the random number
            Have at least 3 dishes that your program can randomly choose
            Highlight the following text if you need a hint:  One way to do this is to make the computer generate a random number: 1, 2, or 3. If the computer generates a 1, then the special dish is "chicken katsu"; if it's a 2, then it's "double cheeseburger"; if it's a 3, then it's "steak and lobster".
        Generate a random number to determine the cost of the special dish for the day.
            Remember to use printf to correctly format monetary values to 2 decimal places
        Ask the user how much money they have. If they have enough money to pay for the dish, give them the dish and change, if applicable. Otherwise, inform them they don't have enough and say goodbye.
            Remember to use printf to correctly format monetary values to 2 decimal places
        Anticipate exceptions and handle them so the program does not crash. (See Example Output below.)
        Note: Your program output does not have to follow the Example Output. The dialogue that your program has with the user can be completely different - be as creative as you wish. :)
    Your program MUST:
        Generate a random special dish/food each time the program runs
        Anticipate and handle any possible exceptions
        Actively use line comments stating what each section of code does
        Consider the possibility of a user not following directions. For example, if you tell them to type 1, 2, or 3, what should your program do if they type -5? As another example, if you tell them to "type yes or no" and they type yES, make sure your program will still accept that as valid input.
    Your program must conform to the Java coding standards reviewed in class.
    Your program should not use code/concepts we have not yet covered. You must demonstrate that you have mastered the concepts covered in class.
    Remember to always begin your code with the following documentation comments:

/**
 * Short description of the program.
 *
 * @author     Last Name, First Name
 * @assignment ICS 111 Assignment XX
 * @date       Today's Date
 * @bugs       Short description of bugs in the program, if any.
 */

Expected Output:

    This is an example of what your program should output:

 ----jGRASP exec: java DoeJohn05
Hi there, what's your name?
JOHN
Hey, John!
My name starts with 'J' too. :)
But it doesn't end with ''... :(n

Anyway! Welcome to my restaurant!
Each day, I offer a special dish at a special price.

Today's dish is:
     chicken curry with rice
     cost:  $100

How much money do you have?
$100.25

Perfect! Here you go! And here is $00.25 in change.
Enjoy your chicken curry with rice! :)
 ----jGRASP: operation complete.

    This is another example of what your program should output:

 ----jGRASP exec: java DoeJohn05
Hi there, what's your name?
JOHN
Hey, john!
My name starts with 'J' too. :)
But it doesn't end with 'n'... :(

Anyway! Welcome to my restaurant!
Each day, I offer a special dish at a special price.
Today's dish is:
     blueberry pancakes with maple syrup
     cost:  $2

How much money do you have?
$ONE MILLION BUCKS

Uhh.. you're supposed to write a monetary amount, like: $1.25
Sorry, try again next time! :)
 ----jGRASP: operation complete.

Criteria:

    Properly anticipating and handling invalid user input
    Complying with Java coding standards
    Properly choosing and displaying random choices and price
    Program flow and clear output/instructions to the user
    Assignment submitted to specifications. For example, documentation comments are included or are complete/correct, file name follow the specified format, your name included in the file name, correct file attached, etc.
   No miscellaneous mistakes, bugs, or problems.

Step by Step Solution

3.51 Rating (161 Votes )

There are 3 Steps involved in it

Step: 1

Required code is import javautilScanner import javautilRandom public class LastNameFirstName05 public static void mainString args Initialize scanner f... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java Programming

Authors: Joyce Farrell

9th edition

1337397075, 978-1337397070

More Books

Students also viewed these Programming questions

Question

How can a change in the discount rate affect commercial loan rates?

Answered: 1 week ago