Write a program that outputs a dentist bill. For members of adental plan, the bi
ID: 3615128 • Letter: W
Question
Write a program that outputs a dentist bill. For members of adental plan, the bill consists of theservice charge (for the particular procedure performed) and testfees, input to the program by the
user. To non-members the charges consist of the aboveservices plus medicine (also input by the
user). The program first asks if the patient is a member ofthe dental plan. The program uses
methods to calculate the total bill. You may use valuereturning methods or void methods to get
the total charge. Name your program Lab9_Ex4.java.
Here is a sample output possible:
Sample Run 1:
Please input a one if you are a member of the dental plan
Input any other number if you are not
1
Please input the service charge
7.89
Please input the test charges
89.56
The total bill is $97.45
Sample Run 2: Please input a one if you are a member of the dentalplan
Input any other number if you are not
2
Please input the service charge
75.84
Please input the test charges
49.78
Please input the medicine charges
40.22
The total bill is $165.84
Explanation / Answer
please rate - thanks import java.util.*; public class untitled { public static void main (String [] args) { int member; double service,test,meds,charge; Scanner input = new Scanner(System.in); System.out.println("Please input a one if you are a member of thedental plan "+ "Input any other number if you are not "); member = input.nextInt(); System.out.println("Please input the service charge "); service = input.nextDouble(); System.out.println("Please input the test charges "); test = input.nextDouble(); if(member==2) {System.out.println("Please input the medicine charges"); meds = input.nextDouble(); charge=nonmembers(service,test,meds); } else charge=members(service,test); System.out.println("The total bill is $"+charge); System.exit(0); } public static double members(double a,double b) { double charge=a+b; return charge; } public static double nonmembers(double a,double b,double c) { double charge=a+b+c; return charge; } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.