Needed for Visual Basics Add a module to your project. In the module, add the fo
ID: 3581152 • Letter: N
Question
Needed for Visual Basics
Add a module to your project. In the module, add the following contents
a. Four public variables: a string variable Conference, a string variable GuestName, a decimal variable Price, and an integer variable Guests. Make all string variables equal to an empty string “” and the rest of the variables equal to 0.
b. Create a public function CalculatePrice that takes two variables by value, a string ConferenceName and an integer NumGuests. The function calculates and returns the total price of the conference registration based on the following rules:
i. IACIS conference costs $495
ii. ISECON costs $395
iii. iConference costs $595
iv. If the participant brings guests, additional $50 is charged per guest
v. If any other value of ConferenceName was passed (not IACIS, ISECON, or iConference), the function returns 0.
Explanation / Answer
Program:
package org.chegg;
import java.util.Scanner;
public class VBModuleProject {
public static String Conference = "";
public String GuestName="";
public static Double Price=0.0;
public static int Guests=0;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter conference name and number of guests:");
Conference = sc.next();
Guests = sc.nextInt();
Price = calculatePrice(Conference,Guests);
System.out.println("Conference Name:" +Conference);
System.out.println("Number of Guests:" +Guests);
System.out.println("Total Price $"+ Price);
}
public static double calculatePrice(String ConferenceName,int NumGuests){
double total = 0.0;
if(ConferenceName.equalsIgnoreCase("IACIS"))
total += 495;
else if(ConferenceName.equalsIgnoreCase("ISECON"))
total += 395;
else if(ConferenceName.equalsIgnoreCase(" iConference"))
total += 595;
else
return 0;
total += NumGuests * 50;
return total;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.