Please i need help with this assigment its Java programming

Please i need help with this assigment! its Java programming

Part I.

Explain in the comments the answer to the following questions. Submit a screenshot of the answers.

1. If a variable is declared in the parameters of a method, is that variable visible in main?

2. If a variable is declared in a method, is that variable visible in main?

3. If a variable is declared in main, is that variable visible to any other methods?

4. What methods can see global/instance variables?

Part II.

We will demonstrate in this part the concept of method overloading. You will create three methods named sum. The first sum method will take in two integer parameters. The second sum method will take in two double parameters. The third and final sum method will take in one integer argument and one double argument. Each method will return a value of the sum of the arguments. The third method will return a double value. In main, print the return values of each method.Please use these test parameters: sum(5, 6), sum(5.3, 6.4), sum(5, 8.5).Submit a screenshot of the output.

Part III.

You will create a McDonald’s Ordering Menu. Create the following static global/instance variables.

double bigMac = 3.49

double fishFil = 3.89

double hamburger = .79

double chickenNuggets = 3.53

double fries = 1.89

double superFries = 2.89

double drink = 1.10

double superDrink = 2.52

double tax = .065

Create a menu method. The menu method will not have a return value. The menu method will not have any parameters. The menu will simply print 4 value menu options for the user to pick from.

1. Big Mac Meal - $6.48

2. Fish o Filet Meal - $6.88

3. Chicken Nugget Meal - $6.52

4. Hamburger Meal - $3.78

Create a method for each value meal. So there should be a bigMacMeal Method, fishFilet Method, chickenNugget Method and a hamburgerMeal Method. Each method will return a total for the meal. The method will start with the corresponding meal total. For example, the Big Mac Meal corresponding total is $6.48. Then the method will ask the user if they want to super-size their fries. If so, then you need to add the additional cost. Then the method will ask the user if they want to super-size their drink. If so, then you need to add the additional cost. The last calculation that the method will perform is the total cost. You will now take your new total (or old total depending on if they did not super-size) and calculate the total cost with taxes (6.5%). This total cost is the value that is being returned to main.

In main, you will first have a print statement that welcome’s you to McDonalds. The program will then call the menu method to print the menu. The user will then select a value meal based upon the integer value. For example, I will enter 1 for a Big Mac Meal. You will use a switch to call the appropriate method based on the selection. The value returned should be printed to the user with the following print statement. You have selected value meal and the total cost is: total cost. Where value meal should represent what meal they picked and total cost represents the total cost returned from the method called.

Test Cases

1. User will pick the Big Mac Meal – No super-size

2. User will pick the Big Mac Meal – With super-size

3. User will pick the Chicken Nugget Meal – With super-size

4. User will pick

6. Invalid selection.

Please submit the screenshot of these cases.

Solution

import java.util.Scanner;

public class Methods {

    public static void menu (){

        System.out.println(\"1. Big Mac Meal - $6.48\");

        System.out.println(\"2. Fish o Filet Meal - $6.88\");

        System.out.println(\"3. Chicken Nugget Meal - $6.52\");

        System.out.println(\"4. Hamburger Meal - $3.78\ \");

    }

    public static void bigMacMeal(Scanner scan, double superFries, double superDrink){

            String userInput;

            double price = 6.48;

            double priceF = 6.48 + superFries;

            double priceD = 6.48 + superDrink;

            double priceB = 6.48 + superFries + superDrink;

            System.out.println(\"Would you like to super size your meal?(Yes/No)\ \");

            userInput = scan.next();

            if (userInput == \"Yes\"){

                price = priceF;

            }else{

                price = price;

            }

            System.out.println(\"Would you like to super size your drink?(Y/N)\ \");

            userInput = scan.next();

            if (userInput == \"Yes\" && price > 7){

                price = priceB;

            }

            if (userInput == \"Yes\"){

                price = priceD;

            }

            if (price = true){

                

            }

            System.out.println(\"Your total is: $\" + price);

        }

    public static void fishFilet(){

        

    }

    public static void chickenNugget(){

        

    }

    public static void hamburgerMeal(){

        

    }

    public static void main(String[] args){

        Scanner scan = new Scanner (System.in);

        

        System.out.println(\"Welcome to Mcdonalds!\ \");

        menu();

        System.out.println(\"What would you like from the menu?(1 - 4)\ \");

        int userInput = scan.nextInt();

        if (userInput == 1){

            bigMacMeal(scan, userInput, userInput);

        }

        if (userInput == 2){

            fishFilet();

        }

        if (userInput == 3){

            chickenNugget();

        }

        if (userInput == 4){

            hamburgerMeal();

        }

        double bigMac = 3.49;

        double fishFil = 3.89;

        double hamburger = .79;

        double chickenNuggets = 3.53;

        double fries = 1.89;

        double superFries = 2.89;

        double drink = 1.10;

        double superDrink = 2.52;

        double tax = .065;

    }

}

Please i need help with this assigment! its Java programming Part I. Explain in the comments the answer to the following questions. Submit a screenshot of the a
Please i need help with this assigment! its Java programming Part I. Explain in the comments the answer to the following questions. Submit a screenshot of the a
Please i need help with this assigment! its Java programming Part I. Explain in the comments the answer to the following questions. Submit a screenshot of the a
Please i need help with this assigment! its Java programming Part I. Explain in the comments the answer to the following questions. Submit a screenshot of the a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site