Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a menu driven program that determines the cost of a new membership. Your program must contain a method that displays the general information about

Write a menu driven program that determines the cost of a new membership. Your program must contain a method that displays the general information about the fitness center and its charges, a method to get all the necessary information to determine the membership cost, and a method to determine the membership cost. Use appropiate parameters to pass information in and out of a method.

Here is my code: please help me find what i'm doing wrong.

package ch7; import java.util.*; /** * * @author Abby Rink */

public class Ch7 {

/** * @param args the command line arguments */ public static void main(String[] args) { basicInfo(); //get info int ch = getinfo(); displayCost(ch); } public static void basicInfo() { //display information System.out.println("basic information about fitness center"); System.out.println ("if you are a senior citizen 30% discount"); System.out.println("If you are already a member in this fitness center" + "and paid 12 months in advance then 15% discount is provided"); System.out.println("normal users don't get a discount"); System.out.println(""); } // get info method public static int getInfo() { System.out.println("Enter your choice: "); System.out.println("1.Enter if senior citizen"); System.out.println("2. if you are already a member"); System.out.println("3: if you have already purchased a membership" ); System.out.println("4:if you are a normal user" ); Scanner sr = new Scanner(System.in); // get choice int choice = sr.nextint(); return choice; } //implementing displayCost()

/** * * @param choice1 */ public static void displayCost(int choice1); { double cost = 8000, result1, result2, result3, result4; switch(choice1) { case 1: result1 = cost - (cost * 0.30); System.out.println("cost after discount is: " + result1); break; case 2: result2 = cost - (cost * 0.15); System.out.println("cost after discount is: "+ result2); break; case 3: result3 = cost - (cost * 0.20); System.out.println("cost after discount is: " + result3); break; case 4: result4 = cost; System.out.println("Cost is: " + result4); break; default: System.out.println("Enter only choices 1-4"); break; } } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 19 21 2012 Proceedings Part 3 Lnai 7198

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284922, 978-3642284922

More Books

Students also viewed these Databases questions

Question

Decision Making in Groups Leadership in Meetings

Answered: 1 week ago