Patient Billing in Java Homework Sample

The user should enter the first and last names of the patient, the claim amount and the billing method. If the billing method is medicare then the amount is 35% of the claim amount. If the billing method is deductible then the bill is 80% of the claim amount minus $50. You should use dialog box for entering the values and parse methods to convert to int or double as appropriate. For more Java assignment help contact us for a quote.

Solution:

PatientBilling.java

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package patientbilling;

import java.util.Scanner;

public class PatientBilling {

public static void main(String[] args) {
String last_name=””;
String name=””;
double claim=0;
int option=0;
Scanner scanner=new Scanner(System.in);

while(true){
System.out.println(“Patient last name (-1 to stop): “);
last_name=scanner.next();
if(last_name.equals(“-1”))
break;

System.out.println(“Patient first name: “);
name=scanner.next();

System.out.println(“Claim amount: “);
claim=scanner.nextDouble();

System.out.println(“Billing method (1 or 2): “);
option=scanner.nextInt();

System.out.println(“\n”);
System.out.println(“Name: “+adjustName(name)+” “+adjustName(last_name));
if(option==1)
System.out.println(“Bill: “+calcBillDeduct(claim));
else
System.out.println(“Bill: “+calcBillMed(claim));
System.out.println(“\n”);
}

}

public static String adjustName(String s){
return s.substring(0, 1).toUpperCase()+s.substring(1).toLowerCase();
}

public static void displayTitle(){
System.out.println(“############Patient Billing Program############\n\n”);
}

public static double calcBillDeduct(double bill){
bill=bill-50;
if(bill<=50)
return 10;
return bill*.8;
}

public static double calcBillMed(double bill){
return bill*.35;
}

}

PatientBillingUI.java

package patientbillingui;

import javax.swing.JOptionPane;

public class PatientBillingUI {

public static void main(String[] args) {
String last_name;
String first_name;

String claimStr;
double claim;
String option;
String output;

do
{
last_name = JOptionPane.showInputDialog (“Enter patient last name (-1 to stop): “);

if(last_name.equals(“-1”))
break;

first_name = JOptionPane.showInputDialog (“Enter patient first name: “);

claimStr = JOptionPane.showInputDialog (“Enter claim amount: “);

claim = Double.parseDouble(claimStr);

option = JOptionPane.showInputDialog (“Enter billing option (1 or 2): “);

output=”Name: “+adjustName(first_name)+” “+adjustName(last_name)+”\n”;
output+=”Bill: “+((option.equals(“1”)?calcBillDeduct(claim):calcBillMed(claim)));

JOptionPane.showMessageDialog (null, output);

}
while (true);
}

public static String adjustName(String s){
return s.substring(0, 1).toUpperCase()+s.substring(1).toLowerCase();
}

public static double calcBillDeduct(double bill){
bill=bill-50;
if(bill<=50)
return 10;
return bill*.8;
}

public static double calcBillMed(double bill){
return bill*.35;
}

}