Question

1. Create a String variable named menuChoice. 2. Display 3 options for your program. I recommend...

1. Create a String variable named menuChoice. 
 
2. Display 3 options for your program. I recommend using 3 System.out.println statements and a 4th System.out.print to show "Enter your Selection:". This needs to be inside the do -- while loop.
 
       A. Deposit Cash.
 
       B. Withdraw Cash
 
       X. Exit
 
       Enter your Selection:
 
3. Prompt for the value menuChoice.
 
4. If menuChoice is "A", display "Do Deposit" and redisplay the menu.
 
    If menuChoice is "B", display "Do withdrawal" and redisplay the menu.
 
    If menuChoice is "X", the loop needs to terminate.
 
    If any other choice is given, display "Invalid selection" and redisplay the menu.

 
For grading, I will test with uppercase characters. Review section 5.1 for String comparisons.

 
5 point bonus - Convert the menuChoice to an upper case String after input or as part of the input but before any processing is done. This will allow me to enter 'a' but process as 'A'. You can Google for "Java string uppercase" to see how this is done.

 
5 point bonus - For Task 4 - Create  2 void methods  - 1 for option A to call, and another for option B to call. Do the display work only inside these methods and call these methods for these options. 
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
_________________

// Demo.java

import java.util.Scanner;

public class Demo {

   public static void main(String[] args) {
       String menuChoice;
       /*
       * Creating an Scanner class object which is used to get the inputs
       * entered by the user
       */
       Scanner sc = new Scanner(System.in);

       while (true) {
           // Getting the input entered by the user
           System.out.println("\nA. Deposit Cash.");
           System.out.println("B. Withdraw Cash");
           System.out.println("X. Exit");
           System.out.print("Enter your Selection:");
           menuChoice = sc.next();

           if (menuChoice.toUpperCase().equals("A")) {
               deposit();
           } else if (menuChoice.toUpperCase().equals("B")) {
               withdraw();
           } else if (menuChoice.toUpperCase().equals("X")) {
               break;
           } else {
               System.out.println("Invalid selection");
           }

       }

   }

   private static void withdraw() {
       System.out.println("Do withdrawal");

   }

   private static void deposit() {
       System.out.println("Do Deposit");
   }

}

_____________________________

Output:


A. Deposit Cash.
B. Withdraw Cash
X. Exit
Enter your Selection:a
Do Deposit

A. Deposit Cash.
B. Withdraw Cash
X. Exit
Enter your Selection:b
Do withdrawal

A. Deposit Cash.
B. Withdraw Cash
X. Exit
Enter your Selection:g
Invalid selection

A. Deposit Cash.
B. Withdraw Cash
X. Exit
Enter your Selection:x

_______________Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
1. Create a String variable named menuChoice. 2. Display 3 options for your program. I recommend...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In this lab, you will create a program to help travelers book flights and hotel stays that will b...

    In this lab, you will create a program to help travelers book flights and hotel stays that will behave like an online booking website. The description of the flights and hotel stays will be stored in two separate String arrays. In addition, two separate arrays of type double will be used to store the prices corresponding to each description. You will create the arrays and populate them with data at the beginning of your program. This is how the arrays...

  • ‘C’ programming language question Write a MENU DRIVEN program to A) Count the number of vowels...

    ‘C’ programming language question Write a MENU DRIVEN program to A) Count the number of vowels in the string B) Count the number of consonants in the string C) Convert the string to uppercase D) Convert the string to lowercase E) Display the current string X) Exit the program The program should start with a user prompt to enter a string, and let them type it in. Then the menu would be displayed. User may enter option in small case...

  • Create a class named Program10. Your program should have the following 4 methods (other helper methods...

    Create a class named Program10. Your program should have the following 4 methods (other helper methods are allowed, but these four methods must be implemented as specified). You need to define a global scanner object and only use it inside the main method and the getValues method, since other methods do not get any values from the input. getValues: This method does not have any input parameter and returns an array of integers. This method prompts the user with a...

  • Your assignment is to create a restaurant ordering system where the cashier can create the menu...

    Your assignment is to create a restaurant ordering system where the cashier can create the menu and then take in the order and display the order back to the customer Sample Execution – Level 1 Welcome to your Menu Creation system. How many items would you like to have on your menu? 2 Create your menu! Enter item #1: Coffee Enter item #2: Tea This is the menu: Coffee Tea What would you like to order? Cake That isn’t on...

  • I need to create a code for this prompt: In this project we will build a...

    I need to create a code for this prompt: In this project we will build a generic UserInput class for getting keyboard input from the user. Implementation: The class UserInput is a 'Methods only' class, and all the methods should be declared static. Look at the TestScanner.java program at the bottom of this page that inputs a string, int and double. It shows you how to use Scanner class to get input from the keyboard. Write FOUR simple methods, one...

  • You will create a class to keep student's information: name, student ID, and grade. The program...

    You will create a class to keep student's information: name, student ID, and grade. The program will have the following functionality: - The record is persistent, that is, the whole registry should be saved on file upon exiting the program, and after any major change. - The program should provide the option to create a new entry with a student's name, ID, and grade. - There should be an option to lookup a student from his student ID (this will...

  • The purpose of this assignment is to get experience with an array, do while loop and...

    The purpose of this assignment is to get experience with an array, do while loop and read and write file operations. Your goal is to create a program that reads the exam.txt file with 10 scores. After that, the user can select from a 4 choice menu that handles the user’s choices as described in the details below. The program should display the menu until the user selects the menu option quit. The project requirements: It is an important part...

  • Sample Execution – Level 3 Welcome to your Menu Creation system. How many items would you...

    Sample Execution – Level 3 Welcome to your Menu Creation system. How many items would you like to have on your menu? 2 Create your menu! Enter item #1: Coffee Enter the number of toppings: 2 Enter topping #1: Whipped Cream Enter topping #2: Cinnamon Enter item #2: Tea Enter the number of toppings: 2 Enter topping #1: Milk Enter topping #2: Sugar May I take your order? This is the menu: Coffee Tea Pop How many items would you...

  • In Java Code Needed is Below the Question Using Program 3: Encapsulating Dogs, modify this program...

    In Java Code Needed is Below the Question Using Program 3: Encapsulating Dogs, modify this program to create a database of dogs of your own. You will also include File I/O with this program. You will create 3 classes for this assignment. The first class: Create a Class representing the information that is associated with one item (one dog) of your database. Name this class Dog. Using Lab 3, this will include the information in regard to one dog. The...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT