Question

In: Computer Science

Problem Description A local veterinarian at The Pet Boutique has asked you to create a program...

Problem Description A local veterinarian at The Pet Boutique has asked you to create a program for her office to create invoices for her patient’s office visits. When a customer brings their pet to the boutique, the clerk gets the Customer’s name, address, phone number and email address, as well as the pets name, pet type, pet age, and pet weight. After the customer sees the Veterinarian, the clerk determines the charges for the services, and medications for the office visit and prints the invoice for the customer’s records. The invoice should include the Customer’s name, address, phone, and email address, the pet’s name, type, age, and weight, service charges, medication charges, sales tax, and the total charges for the office visit. All calculations should take place in the class methods. All display should use method calls to the get methods from the classes to display the appropriate information. Do not accept any numbers that are less than or equal to zero. Calculate the sales tax using a constant equal to .0925 and limit the display to two decimal places. in Java

Solutions

Expert Solution

check out the solution and do COMMENT for any doubts or modifications.

---------------------------------------------------------------------------------------

// import required classess
import java.util.*;

// class 'botique'
class Botique {
// class variables
String cname, caddress, cemail, pname, ptype;
int cphone, page, pweight;
  
// all calculations are done with class methods
// setters - sets the given variable values to class variables
void setCName(String cname) {
this.cname = cname;
}
void setCAddress(String a) {
this.caddress = a;
}
void setCEmail(String e) {
this.cemail = e;
}
void setPName(String pname) {
this.pname = pname;
}
void setPType(String pt) {
this.ptype = pt;
}
void setCPhone(int ph) {
this.cphone = ph;
}
void setPAge(int age) {
this.page = age;
}
void setPWeight(int pw) {
this.pweight = pw;
}
  
// does the calculations for charges
// getters - gets the class variables values
String getCName() {
return cname;
}
String getCAddress() {
return caddress;
}
String getCEmail() {
return cemail;
}
String getPName() {
return pname;
}
String getPType() {
return ptype;
}
int getCPhone() {
return cphone;
}
int getPAge() {
return page;
}
int getPWeight() {
return pweight;
}
  
// charges
double getSCharge() {
// as formula or criteria not specified for charges calculations.
// assuming some random values between 200 - 500 for service and medication charge.
double scharge;
scharge = (Math.random()*((500.0-200.0)+1))+200.0;
return scharge;
}
double getMCharge() {
double mcharge;
mcharge = (Math.random()*((500.0-200.0)+1))+200.0;
return mcharge;
}
// pass service and medication charge to find total charge along with sales tax
double getTCharge(double sc,double mc) {
double tcharge;
// given sales tax
double stax = 0.0925;
tcharge = sc + mc + stax;
return tcharge;
}
  
}
// main class
public class MyClass {
public static void main(String args[]) {
// required declarations
String cname, caddress, cemail, pname, ptype;
int cphone, page, pweight;

// create a Scanner class object to read user input
Scanner sc = new Scanner(System.in);
Scanner sc1 = new Scanner(System.in);
  
// create a botique object to access its elements
Botique bq = new Botique();
  
System.out.println("Input the details : ");
System.out.print("Customer's Name : ");
cname = sc.nextLine();
System.out.print("Address : ");
caddress = sc.nextLine();
  
// validation for integers
while(1) {
System.out.print("Input Valid Phone number : ");
cphone = sc.nextInt();
if (cphone > 0)
break;
}
System.out.print("Email address : ");
cemail = sc.next();
System.out.print("Pet's Name : ");
pname = sc.nextLine();
System.out.print("Pet's Type : ");
ptype = sc.nextLine();
// validation for integers
while(1) {
System.out.print("Input Valid Pet's age : ");
page = sc.nextInt();
if (page > 0)
break;
}
while(1) {
System.out.print("Input Valid Pet's Weight : ");
pweight = sc1.nextInt();
if (page > 0)
break;
}
  
// set the user input to class variables
bq.setCName(cname);
bq.setCAddress(caddress);
bq.setCEmail(cemail);
bq.setPName(pname);
bq.setPType(ptype);
bq.setCPhone(cphone);
bq.setPAge(page);
bq.setPWeight(pweight);
  
// print as required with 'get()' methods
System.out.println("\n\n------------Invoice--------------");
System.out.println("Customer's Name : " + bq.getCName());
System.out.println("Address : " + bq.getCAddress());
System.out.println("Phone number : " + bq.getCPhone());
System.out.println("Email address : " + bq.getCEmail());
System.out.println("Pet's Name : " + bq.getPName());
System.out.println("Pet's Type : " + bq.getPType());
System.out.println("Pet's age : " + bq.getPAge());
System.out.println("Pet's Weight : " + bq.getPWeight());
  
double scharge = bq.getSCharge();
double mcharge = bq.getMCharge();
double tcharge = bq.getTCharge(scharge, mcharge);
  
System.out.printf("\nService charges : $ %.2f" , scharge);
System.out.printf("\nMedication charges : $ %.2f" , mcharge);
System.out.printf("\nSales tax : $ 0.0925");
System.out.printf("\n\nTotal charges : $ %.2f" , tcharge);
  
}
}


Related Solutions

PYTHON IS3073 1. A group of statisticians at a local college has asked you to create...
PYTHON IS3073 1. A group of statisticians at a local college has asked you to create a set of functions that compute the median and mode of a set of numbers, as defined in Section 5.4. Define these functions in a module named stats.py. Also include a function named mean, which computes the average of a set of numbers. Each function should expect a list of numbers as an argument and return a single number. Each function should return 0...
The local driver's license office has asked you to design a program that grades the written...
The local driver's license office has asked you to design a program that grades the written portion of the driver's license exam. The exam has 20 multiple choice questions. Here are the correct answers: B D A A C A B A C D B C D A D C C B D A Your program should store these correct answers in an list. (Store each question's correct answer in an element of a String list). The program should ask...
The local driver's license office has asked you to design a program that grades the written...
The local driver's license office has asked you to design a program that grades the written portion of the driver's license test. The test has 20 multiple choice questions. Here are the correct answers: B D A A C A B A C D B C D A D C C B D A Your program should store these correct answers in an list. (Store each question's correct answer in an element of a String list). The program should ask...
Program Description A local company has requested a program to calculate the cost of different hot...
Program Description A local company has requested a program to calculate the cost of different hot tubs that it sells. Use the following instructions to code the program: File 1 - HotTubLastname.java Write a class that will hold fields for the following: The model of the hot tub The hot tub’s feature package (can be Basic or Premium) The hot tub’s length (in inches) The hot tub’s width (in inches) The hot tub’s depth (in inches) The class should also...
Use JAVAfor this program Program Description You work in a local gift shop that is currently...
Use JAVAfor this program Program Description You work in a local gift shop that is currently running a large sale. You have been asked to create a program to calculate the total of a user’s purchases and determine if they qualify for a discount. Use the following steps to create the program: Ask the user the price of the item they wish to purchase. Ask the user the quantity they wish to purchase. Ask the user to enter the name...
You are volunteering for a local children's softball league. They asked you to create an app...
You are volunteering for a local children's softball league. They asked you to create an app or a Web application to help in their operations. You decide to create a database. The league consists of several teams. Players are assigned to teams at the start of the season. It also collects parents' contact information, and charges season and optional equipment rental fees. League volunteers include officials, referees, coaches, and first aid attendants. Parents also volunteer to help at individual practices...
Python Problem Problem 1: In this problem you are asked to write a Python program to...
Python Problem Problem 1: In this problem you are asked to write a Python program to find the greatest and smallest elements in the list. The user gives the size of the list and its elements (positive and negative integers) as the input. Sample Output: Enter size of the list: 7 Enter element: 2 Enter element: 3 Enter element: 4 Enter element: 6 Enter element: 8 Enter element: 10 Enter element: 12 Greatest element in the list is: 12 Smallest...
Coding Problem 1: In this program, you are asked to write a program in assembly (MIPS)...
Coding Problem 1: In this program, you are asked to write a program in assembly (MIPS) which works as a simple calculator. The program will get two integer numbers, and based on the requested operation, the result should be shown to the user. a. The program should print a meaningful phrase for each input, and the result. i. “Enter the first number” ii. “Enter the second number” iii. “Enter the operation type” iv. “The result is” b. The user should...
Program this in C thank you PROBLEM DESCRIPTION: Write a program to implement the following requirement:...
Program this in C thank you PROBLEM DESCRIPTION: Write a program to implement the following requirement: The program will read from standard input two things - a string str1 on the first line of stdin (this string may be an empty string) - a string str2 on the second line of stdin (this string may be an empty string) Note that stdin does not end with '\n'. The program will output a string that is the concatenation of string str1...
Imagine that you are asked to create a dissemination plan for a health promotion program. You...
Imagine that you are asked to create a dissemination plan for a health promotion program. You have just learned that most of the stakeholders that you planned to present to are leaving the country in two weeks and will be gone for the next six months, so you must present your findings to them before they leave. Originally, you had three months to prepare your dissemination plan. Do you think that the plan should be disseminated as it would be...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT