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

Due Friday by 11:59pm Points 50 Submitting a file upload File Types zip For this

ID: 3730551 • Letter: D

Question

Due Friday by 11:59pm Points 50 Submitting a file upload File Types zip For this lab, you will create a program that uses method overloading and a switch statement. HCC Celebrates Columbia's 50th Birthday, Inc. needs to distribute tickets for a gala which will be held at Howard Community College's Horowitz Visual and Performing Arts Center. You have been asked to write a program which will distribute tickets based on the attendee's membership in the Columbia Association using one of two methods. Requirements: This program will need to do the following: When the program is run, the user will be asked if he or she belongs to the Columbia Association (CA). If the user answers "yes", the program will call a method that returns a string for the type of ticket which is "VIP" If the user answers "no", the program will ask how much the person is willing to donate. The program will return a string for the type of ticket to distribute based on the donation amount found in the table below: Donation 10 50 100 Any other value Type of ticket Attendee Bronze Attendee Silver Attendee Gold Attendee Custom Donation Attendee You should use a switch statement to implement the table, and you should not use the reserve word "return" within the switch statement. NOTE: Both the method which returns "VIP" for CA members and the method which returns a ticket type based on a donation for non-CA members must be named exactly the same. This code should all be contained within one java file.

Explanation / Answer

package Mar15th;

import java.util.Scanner;

/*

*

* Method Overloading is having the same method name with different number of ,order of ,type arguments,

* in our program we have getAttendeMemberShip() method as without argument and with one int argument so here

* getAttendeMemberShip() is overloaded

* default : if given value is not matched with any of the case than default case will get executed, in our case if user enters other than 5,10,50,100 than we should return Custom donation

* so in default case i am assigning Custom donation

*/

public class HccCelebrations {

public String getAttendeMemberShip(){

return "VIP";

}

public String getAttendeMemberShip(int amount){

String res="";

switch(amount){

case 5:

res = "Attendee";

break;

case 10:

res = "Bronze Attendee";

break;

case 50:

res = "Silver Attendee";

break;

case 100:

res = "Gold Attendee";

break;

default:

res = "Cusotm Donation Attendee";

break;

}

return res;

}

public static void main(String[] args) {

HccCelebrations hcc = new HccCelebrations();

Scanner sc = new Scanner(System.in);

String choice="";

String ticket="";

System.out.println("Are you Belongs to Columbia Association? type yer or no");

choice = sc.nextLine();

if(choice.equalsIgnoreCase("yes")){

ticket = hcc.getAttendeMemberShip();

}

else{

int amount=0;

System.out.println("How much your willing to donate");

amount = sc.nextInt();

ticket=hcc.getAttendeMemberShip(amount);

}

sc.close();

System.out.println("Ticket : "+ticket);

}

}

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