- Joined
- Mar 15, 2021
- Messages
- 1
- Reaction score
- 0
Please anybody help me to find out the error?
import java.util.*;
public class Customer {
public String customerId;
public String customerName;
public long contactNumber;
public String address;
public void displayCustomerDetails() {
System.out.println("Displaying customer details \n***********");
System.out.println("Customer Id : " + customerId);
System.out.println("Customer Name : " + customerName);
System.out.println("Contact Number : " + contactNumber);
System.out.println("Address : " + address);
System.out.println();
}
public void payBill(double totalPrice, double discountPercentage) {
System.out.println("Calculating final amount to be paid......");
double priceAfterDiscount = totalPrice * (1 - (discountPercentage / 100));
System.out.println("Hi " + customerName + ", your final bill amount after discount is: " + (int) (priceAfterDiscount * 100) / 100.0);
}
class Test{
public static void main(String args[]) {
Customer customer = new Customer();
customer.customerId = "C101";
customer.customerName = "Stephen Abram";
customer.contactNumber = 7856341287L;
customer.address = "D089, St. Louis Street, Springfield, 62729";
customer.displayCustomerDetails();
}
customer.payBill(500, 10);
}
import java.util.*;
public class Customer {
public String customerId;
public String customerName;
public long contactNumber;
public String address;
public void displayCustomerDetails() {
System.out.println("Displaying customer details \n***********");
System.out.println("Customer Id : " + customerId);
System.out.println("Customer Name : " + customerName);
System.out.println("Contact Number : " + contactNumber);
System.out.println("Address : " + address);
System.out.println();
}
public void payBill(double totalPrice, double discountPercentage) {
System.out.println("Calculating final amount to be paid......");
double priceAfterDiscount = totalPrice * (1 - (discountPercentage / 100));
System.out.println("Hi " + customerName + ", your final bill amount after discount is: " + (int) (priceAfterDiscount * 100) / 100.0);
}
class Test{
public static void main(String args[]) {
Customer customer = new Customer();
customer.customerId = "C101";
customer.customerName = "Stephen Abram";
customer.contactNumber = 7856341287L;
customer.address = "D089, St. Louis Street, Springfield, 62729";
customer.displayCustomerDetails();
}
customer.payBill(500, 10);
}