Question
Please !create a java program for the follwing question.

19. The cost to become a member of a fitness center is as follows: (a) the Senior citizens discount is 30%; (b) if the member
0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.*;

class CenterCost
{
   static Scanner sc = new Scanner(System.in);
  
   //method to display general Information
   static double generalInfo()
   {
       System.out.println("***** Welcome to Fitness Center *****");
      
       System.out.println();
      
       System.out.println("Monthly charges $20");
       System.out.println("Yearly charges $160");
       System.out.println("Weekly charges $7");
      
       Scanner sc = new Scanner(System.in);
      
       System.out.print("Enter charges: ");
      
       double charges = sc.nextDouble();
      
       return charges;
   }
  
   //method to get information
   static int getInfo(double charges)
   {
       System.out.println("1. Senior citizens discount 30%");
  
       System.out.println("2. Membership brought and paid for 12 more months, discount is 15% ");
  
       System.out.println("3. More than five personal training section are purchased, discount is 20%");
      
       System.out.println("Enter your option (1-3): ");
  
       int option = sc.nextInt();
      
       return option;  
   }
  
   //method to determine the cost
   static double calculateCost(int option, double charges)
   {
       double netcost;
      
       switch(option)
       {
           case 1:
               netcost = charges * 0.7;
               break;
           case 2:
               netcost = charges * 0.85;
               break;
           case 3:
               netcost = charges * 0.80;
               break;
           default: System.out.println("Wrong Input");
           netcost = 0;
       }
      
       return netcost;
   }
  
   //main method
   public static void main (String[] args)
   {
       double charges = generalInfo();
      
       int option = getInfo(charges);
      
       double netcost = calculateCost(option, charges);
      
       System.out.println("Discounter membership cost is " + netcost);
   }
}

Output::

***** Welcome to Fitness Center *****

Monthly charges $20
Yearly charges $160
Weekly charges $7
Enter charges: 160
1. Senior citizens discount 30%
2. Membership brought and paid for 12 more months, discount is 15%
3. More than five personal training section are purchased, discount is 20%
Enter your option (1-3):
2
Discounter membership cost is 136.0

Add a comment
Know the answer?
Add Answer to:
Please !create a java program for the follwing question. 19. The cost to become a member...
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
  • - The senior citizens discount is 30% e If the membership is bought and paid for...

    - The senior citizens discount is 30% e If the membership is bought and paid for 12 or more months, the discount is 15% . If more than five personal training sessions are bought and paid for, the discount on each session is 20%. Write a menu-driven program that determines the cost of a new membership. Your program must contain a function that displays the general information about the fitness center and its charges, a function to get all of...

  • Write a java program. The cost to join a gym is: 1) Senior citizens: get a...

    Write a java program. The cost to join a gym is: 1) Senior citizens: get a 30% discount. 2.) If twelve or more months in advance are bought and paid for, a 15% discount is applied to the membership. The user enters the number of months. 3) Personal Training sessions: 20% discount on each session if more than 12 are bought. This will be a menu-driven, GUI program that determines the cost of a new membership.Using JTextField for input and...

  • C++ exercises During the tax season, every Friday, the J&J accounting firm provides assistance to people...

    C++ exercises During the tax season, every Friday, the J&J accounting firm provides assistance to people who prepare their own tax returns. Their charges are as follows: If a person has low income (<= 25,000) and the consulting time is less than or equal to 30 minutes, there are no charges; otherwise, the service charges are 40% of the regular hourly rate for the time over 30 minutes. For others, if the consulting time is less than or equal to...

  • C++ Question Question 3 [43] The Question: You are required to write a program for an...

    C++ Question Question 3 [43] The Question: You are required to write a program for an Online Tutoring Centre to determine the weekly rate depending on the number of sessions the students attend and then to calculate total revenue for the center. The Online Tutoring Centre charges varying weekly rates depending on the on grade of the student and number of sessions per week the student attends as shown in Table 1 below. Grade 8 9 Session 1 75 80...

  • Write a Java program to read customer details from an input text file corresponding to problem...

    Write a Java program to read customer details from an input text file corresponding to problem under PA07/Q1, Movie Ticketing System The input text file i.e. customers.txt has customer details in the following format: A sample data line is provided below. “John Doe”, 1234, “Movie 1”, 12.99, 1.99, 2.15, 13.99 Customer Name Member ID Movie Name Ticket Cost Total Discount Sales Tax Net Movie Ticket Cost Note: if a customer is non-member, then the corresponding memberID field is empty in...

  • Question: I do no understand this week's JAVA programming project, which is a program that mimics...

    Question: I do no understand this week's JAVA programming project, which is a program that mimics ticket purchases for train objects. It is a train class that includes: 5 static constants. The five values can be seen in the Method descriptions below. There were no static constants provided, but my best guess is: kidTicketCost (cost of kids ticket is $7.50) adultTicketCost (adult ticket cost is $14.50) ageOfKid (age of the kid) ageOfAdult,(age of the adult) trainSeatStatus. (checks to see if...

  • Java please answer A to I please dont type the answer on paper please use the...

    Java please answer A to I please dont type the answer on paper please use the computer A.   Explain why alpha cannot be accessed by other members of its class. B.   In the program, how can you determine the type of access modifier? C.   Describe the differences and similarities of beta and gamma in program, within the context of access specifiers and class member accessibility. D.   Explain how objects, a and b, are passed to the method. E.    Why...

  • Industrial Psychology: Please read the case above before answering the following question: What changes would you...

    Industrial Psychology: Please read the case above before answering the following question: What changes would you suggest that could increase the transfer of training in this case? What Went Wrong at University Hospital (Part 1)? Pat Rowe, Vice President of University Hospital, recently attended a conference session that discussed the problems of integrating computer technology into the work practices of health care professionals. The session lecturer argued that implementation often fails because staff do not receive proper training in the...

  • (2 bookmarks) In JAVA You have been asked to write a program that can manage candidates...

    (2 bookmarks) In JAVA You have been asked to write a program that can manage candidates for an upcoming election. This program needs to allow the user to enter candidates and then record votes as they come in and then calculate results and determine the winner. This program will have three classes: Candidate, Results and ElectionApp Candidate Class: This class records the information for each candidate that is running for office. Instance variables: first name last name office they are...

  • You will write a two-class Java program that implements the Game of 21. This is a...

    You will write a two-class Java program that implements the Game of 21. This is a fairly simple game where a player plays against a “dealer”. The player will receive two and optionally three numbers. Each number is randomly generated in the range 1 to 11 inclusive (in notation: [1,11]). The player’s score is the sum of these numbers. The dealer will receive two random numbers, also in [1,11]. The player wins if its score is greater than the dealer’s...

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