Question

In: Computer Science

The first step in writing a software application is to determine the requirements. There is no...

The first step in writing a software application is to determine the requirements. There is no value in writing a program that does not address the needs of the client. Requirements can be gathered in many ways, but ultimately, the requirements serve to document what the application should and should not do. After the requirements are written, the application design can be prepared, followed by the actual coding. For this project, you will gain some practice in the design phase of software development by designing a program that will meet a given set of requirements.

In this assignment you will develop a console program that simulates a restaurant menu. The project instructions are as follows:

Program Requirements:

  1. Each item on the menu must have a different price.
  2. Your menu must define at least 10 different items.
  3. Program Requirements:
    • Display the menu to the user.
    • Allow the user to select an item from the menu. (Record the selection in a variable.)
    • Once the user has selected an item, ask them how many they want (quantity). (Record the quantity in a variable.)
    • Calculate the total. (Sales tax is not included in this exercise.)
    • Ask the user to enter the amount of their payment. (Record this amount in a variable.)
    • Subtract the order total from the payment amount and present any remainder on screen as the customer’s “change”.
    • Remind the program operator to thank the customer for their patronage.
  4. Remember to test your program fully to ensure that all functions operate correctly.
  5. Netbean Language

Solutions

Expert Solution

Restaurant.java


import java.util.Scanner;
public class Restaurant {
   public static void displayMenu(String[] items, double [] prices) {
       for(int i=0; i<items.length; i++)
           System.out.printf("%d. %-15s : %.2f\n", i+1, items[i], prices[i]);
   }
   public static void main(String[] args) {
       String[] items = {"Dhokla", "Bhelpuri", "Tikki", "Dahi bhalla", "Chowmin", "Burger",
               "Lachha Tokri", "Manchurian", "Choupsuey", "Spring Roll"};
       double [] prices = {1, 2, 3.0, 4.5, 1.2, 2.2 ,3.8, 10.2, 0.5, 5.6};
      
      
       //Array to store indices of items ordered by the customer
       //If order[i] = 1, means ith item has been ordered
       int[] order = new int[10];      
       //Array to store quantities of items ordered by customer
       //quantity[i] = 4 means 4 quantity of ith item has been ordered
       int[] quantity = new int[10];
      
      
       String choice = "no";
       Scanner scan = new Scanner(System.in);
       do {
           //Display menu
           displayMenu(items, prices);
           //Ask for choice
           System.out.println("Enter which item you want to include in your order (1-10):");
           int k = scan.nextInt();
           order[k-1] = 1;
           //Ask for quantity
           System.out.println("Enter the quantity: ");
           int q = scan.nextInt();
           quantity[k-1] = q;
          
           //More items?
           System.out.println("Do you want to add more item in your order? yes/no");
           choice = scan.next();
       }while(!choice.contentEquals("no"));
      
       //Calculating total price
       double sum = 0;
       for(int i=0; i<order.length; i++) {
           //If ith item has been ordered
           if(order[i]!=0) {
               sum += quantity[i]*prices[i];
           }
       }
       System.out.println("Total payment due:" + sum);
       System.out.println("Your payment: ");
       double payment = scan.nextDouble();
       if(payment>sum)
           System.out.println("Change: " + (payment-sum));
      
       System.out.println("Thank you for visiting.\nHave a nice day.");
   }
}


Related Solutions

Subject: Software, Architecture Design and Testing You are to determine the user requirements for a web...
Subject: Software, Architecture Design and Testing You are to determine the user requirements for a web phone-mail product. The primary purpose of this product is to give phone-mail users (e.g., faculty and staff) the ability to access the functionality of the phone-mail system from a web page. In general, the product should enable users of the phone-mail system to do their usual phone-mail activities via a web page. Evaluate these requirements. Do your requirements satisfy the eight criteria: Understandable, Verifiable,...
You are required to design a VoIP application. Discuss the requirements for such an application in...
You are required to design a VoIP application. Discuss the requirements for such an application in terms of its protocols and performance requirements. What types of protocols you would need to design a complete VoIP application (Hint: real time streaming protocols and signaling protocols, etc.)? [5 Marks] 2. Discuss the architecture of messanging app in terms of its protocols. Address and discuss all the essential protocols used by messaging app for communication.
1. There are two steps for evaluating argument, the first step is to determine the logical...
1. There are two steps for evaluating argument, the first step is to determine the logical strength of the argument and the second step is to determine the truth value of the premises. Please discuss whether this 2-step evaluation is good. 2. Informal fallacy can be divided into 4 classes: inconsistence, irrelevancy, insufficiency and inappropriate presupposition. It is called "4I" classification. Discuss whether it Is a good classification.
The first step in selecting a Shewhart chart is to determine the type of data you...
The first step in selecting a Shewhart chart is to determine the type of data you are collecting. For this discussion, identify and discuss the 2 types of data that can be used with this type of chart. What are some examples of each type? Be sure to discuss the subdivision of each type. Based upon your response to these questions, why is this step so important? What would happen if you skipped it?
1. You are required to design a VoIP application. Discuss the requirements for such an application...
1. You are required to design a VoIP application. Discuss the requirements for such an application in terms of its protocols and performance requirements. What types of protocols you would need to design a complete VoIP application (Hint: real time streaming protocols and signaling protocols, etc.)? [5marks] 2. Discuss the architecture of WhatsApp in terms of its protocols. Address and discuss all the essential protocols used by WhatsApp for communication. [5 Marks]
Defining Requirements - The next step is to identify the essential requirements for the information system....
Defining Requirements - The next step is to identify the essential requirements for the information system. In addition to the stakeholder interests identified above, review the Case Study, especially the interviews, highlighting any statements that tell what the person expects the system to do. Functional requirements express specifically what the user needs the system to do. This can be in terms of tasks the users need to perform, data they need to input, what the system might do with that...
Part 1: The first step in the retirement planning process is A) the determine how funds...
Part 1: The first step in the retirement planning process is A) the determine how funds required to meet retirement needs will be accumulated. B) to estimate future income needs. C) to determine the benefits that will be available under social security. D) convert the estimated flow of income needed into a principal amount. Part 2: The Social Insurance Supplement Benefit A) is designed for those occupations not covered by OASDI. B) permits one to coordinate disability insurance with social...
Software security: Assume you are performing preliminary security risk assessment. 1. The first step in performing...
Software security: Assume you are performing preliminary security risk assessment. 1. The first step in performing a preliminary risk assessment is asset identification. List down three assets you identify in an in-store automated supermarket shopping system when conducting the preliminary risk assessment. 2. Identify two possible security risks associated with an in-store supermarket shopping system and propose a system requirement that might reduce each of those risks.
Please clear writing and explain step by step this should be a simple question Consider the...
Please clear writing and explain step by step this should be a simple question Consider the function f : [0,1]→R defined by (f(x) =0 if x = 0) and (f(x)=1 if 0 < x≤1) (i)Compute L(f) andU(f). (ii) Is f Riemann integrable on [0,1]?
I need to know how to properly complete this question step by step in writing as...
I need to know how to properly complete this question step by step in writing as well as using the ti-84?: Random and independent samples of 900 men and 1200 women were asked if they believe that a good diet was very important to good health. Sample results are as follows women men believes a good diet is important 924 603 sample size 1200 900 conduct the appropriate hypothesis test to see if the proportion of all men who hold...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT