Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Code a program that will calculate customer bills based on boarding profiles. Th

ID: 3887948 • Letter: C

Question

Code a program that will calculate customer bills based on boarding profiles. The boarding profiles will be read from the text file boarding.txt. Process the text file in such a way that it can handle a similarly formatted file that contains any number of boarding profiles.

The text file contains profile information in the following order:

Customer's first name

Customer's last name

Dog's breed

Dog's weight

Number of boarding days

An additional $20.00 fee is added for boarding high risk breeds:

Pit bull

Doberman

Rottweiler

Display the following output:

The title (same title that was used in Project 1)

The customer's first and last name

The dog's breed

The dog's weight

The number of boarding days

Subtotal (this includes the fee for high risk breeds)

Tax

Total (Subtotal plus tax amount)

The total amount for all bills in the billing cycle

Notes:

You will design an IPO chart with this project but you will submit the IPO chart with Project 3.

The text file should not be edited. Your program should be able to process the file as is.

The Scanner class must be used to read and process the file.

This is a continuation of Project 1. You will use the same information from Project 1 to calculate the fees. The only additional fee is the fee for high risk dogs. Tax is 6%.

All money output should be formatted correctly (i.e., $, 00.00).

An error occurs if your Java program tries to read a file that is not accessible. Java calls errors like these Exceptions. You will learn how to handle exceptions if you take CSC251. For now, it is sufficient to state the error might occur. Include the following at the end of your main method: public static void main(String[ ] args) throws IOException

Sample Output

Madison Kennel & Grooming

(two blank lines here)

Customer:

Breed:

Weight: xx.x pounds

Boarding days: xx days(s)

Subtotal for xx days: $xx.xx

Tax amount: $xx.xx

Total due: $xx.xx

Blank line between each account

Two blank lines after the last account

Total Fees for a billing cycle: $xx.xx

Information in File is

Sally
Smith
Poodle
5
7

Mark
Johnson
Pit Bull
20
5

Mike
Hampton
Hound
13
3

Dave
Bryant
Doberman Pinscher
25
4

Vivian
Jones
Rottweiler
30
2

Regina
Medley
Husky
35
8

Explanation / Answer

import java.io.*;
import java.util.*;

class Customer {
   
       public String fname;
       public String lname;
       public String breed;
       public double weight;
       public int num_days;
}


public class DemoBoarding {
    public static void main(String[] args) throws IOException{

       String fname;
       String lname;
       String breed;
       double weight;
       int num_days=0;
       double subtotal = 0;
       double total_bill = 0;
       double price_per_day = 200;
       try {

              File file = new File("boarding.txt");
              Scanner sc = new Scanner(file);
              ArrayList<Customer> data = new ArrayList<Customer>();
              Customer c = new Customer();
              while (sc.hasNext()){
                   c.fname = sc.nextLine();
                   c.lname = sc.nextLine();
                   c.breed = sc.nextLine();
                   c.weight = Integer.parseInt(sc.nextLine());
                   c.num_days = Integer.parseInt(sc.nextLine());             
                   data.add(c);
              }
              System.out.println("Madison Kennel & Grooming ");

              for (int i = 0; i<data.size(); i++){
                  System.out.println("Customer : " + data.get(i).fname + " " + data.get(i).lname);
                  System.out.println("Breed : " + data.get(i).breed);
                  System.out.println("Boarding Days : " + data.get(i).num_days);
                  subtotal = data.get(i).num_days * price_per_day;
                  if (data.get(i).breed.equals("Pit Bull") || data.get(i).breed.equals("Doberman") || data.get(i).breed.equals("Rottweiler"))
                     subtotal = subtotal + 20;              
                  System.out.println("Subtotal for " + data.get(i).num_days + " days: $" + String.format("%.2f",subtotal));
                  System.out.println("Tax amount : $" + String.format("%.2f",subtotal * 0.06));
                  System.out.println("Total amount : $" + String.format("%.2f",subtotal * 0.06 + subtotal));
                  total_bill = total_bill + subtotal * 0.06 + subtotal;
                  System.out.println(" ");

              }
              System.out.println("Total fees for billing cycle :" + String.format("%.2f",total_bill));

       }
       catch(Exception e){
             e.printStackTrace();
       }
    }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote