Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java: code a value-receiving method called costumes() that receives a number for

ID: 3807214 • Letter: J

Question

Java: code a value-receiving method called costumes() that receives a number for a party event. Inside this method is a switch statement that tests partyEvent so when partyEvent is 1 the value returning method valenties is called; when 2 the value returning method mariGras is called; when 3 the value returning method halloween is called; and when it is not any of the above the message"The Party you want is not planned!" is displayed. THe methods valentines, mardiGras, and halloween return the number of attendees for each respective party event which are added to a global variable called totalAttendees that is already declared.

*doesn't run infinintely*

Explanation / Answer

Note: Tested on ubuntu

/************************************Event.java*************************************/


import java.util.Scanner;


/**
*
* @author Lalchand Mali
*/
public class Event {
    /**
     * Variable declaration
     */
    /**
     * Total Number of valentineAttendees.
     */
    int valentineAttendees = 100;
    /**
     * Total Number of mardiGrasAttendees.
     */
    int mardiGrasAttendees = 40;
    /**
     * Total Number of halloweenAttendees.
     */
    int halloweenAttendees = 50;
  
    int valenties() {
        return this.valentineAttendees;
    }
    int mariGras() {
        return this.mardiGrasAttendees;
    }
    int halloween() {
        return this.halloweenAttendees;
    }
    public static void main(String args[]){
        /**
         * Variable declaration
         */
        int result;
        Event event = new Event();
        Scanner input =new Scanner(System.in);
        System.out.println("Please enter the number for party event");
        int partyEvent = input.nextInt();
        switch(partyEvent) {
            case 1:
                result = event.valenties();
                System.out.println("Total Number of Attendees: " +result);
                break;
            case 2:
                result = event.mariGras();
                System.out.println("Total Number of Attendees: " +result);
                break;
            case 3:
                result = event.halloween();
                System.out.println("Total Number of Attendees: " +result);
                break;
            case 4:
                System.out.println("The Party you want is not planned!");
                break;
        }
    }
}


/**********************************output*******************************/

lalchand@lalchand:~/Desktop/Chegg-java$ javac Event.java
lalchand@lalchand:~/Desktop/Chegg-java$ java Event
Please enter the number for party event
1
Total Number of Attendees: 100
lalchand@lalchand:~/Desktop/Chegg-java$ java Event
Please enter the number for party event
2
Total Number of Attendees: 40
lalchand@lalchand:~/Desktop/Chegg-java$ java Event
Please enter the number for party event
3
Total Number of Attendees: 50
lalchand@lalchand:~/Desktop/Chegg-java$ java Event
Please enter the number for party event
4
The Party you want is not planned!

Thanks a lot

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote