Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
3.8 kB
3
Indexable
Never
package term1;

import java.util.Scanner;

class Customer {
	private	String name;
	private	String address;
	private	Integer age;
	private	String mobileNumber;
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public String getMobileNumber() {
		return mobileNumber;
	}

	public void setMobileNumber(String mobileNumber) {
		this.mobileNumber = mobileNumber;
	}
	
	public Customer(String name, String address, Integer age, String mobileNumber) {
		super();
		this.name = name;
		this.address = address;
		this.age = age;
		this.mobileNumber = mobileNumber;
	}

	// fill your code here

	void displayCustomer() {
		//fill your code here
		System.out.println("Bill Details"
				+ "\nName " + this.name
				+ "\nMobile "+ this.mobileNumber
				+ "\nAge "+this.age
				+ "\nAddress "+this.address);
	}
}



class SeniorCitizenCustomer extends Customer{
	
	public SeniorCitizenCustomer(String name, String address, Integer age, String mobileNumber) {
		super(name, address, age, mobileNumber);
		// TODO Auto-generated constructor stub
	}

	//fill your code here
	
	double getBillAmount(Double amount) {
		//fill your code here
		return amount*88/100;
	}

}

class PrivilegeCustomer extends Customer{
	
	public PrivilegeCustomer(String name, String address, Integer age, String mobileNumber) {
		super(name, address, age, mobileNumber);
		// TODO Auto-generated constructor stub
	}

	//fill your code here
	
	double getBillAmount(Double amount) {
		//fill your code here
		return amount*70/100;
	}

}

public class demo2 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		System.out.println("1)Privilege Customer"
				+ "\n2)SeniorCitizen Customer"
				+ "\nEnter Customer Type");
		int chose = s.nextInt();
		switch (chose) {
		case 1:
		{
			System.out.println("Enter The Name");
			String name = s.nextLine();
			System.out.println("Enter The Age");
			int age = s.nextInt();
			System.out.println("Enter The Address");
			String address = s.nextLine();
			System.out.println("Enter The Mobile Number");
			String mobileNumber = s.nextLine();
			System.out.println("Enter The Purchased Amount");
			double amount = s.nextDouble();
			PrivilegeCustomer p = new PrivilegeCustomer(name, address, age, mobileNumber);
			p.displayCustomer();
			System.out.format("Your bill amount is Rs %.1f. Your bill amount is discount under privilege customer",amount);
			System.out.format("You have to pay Rs %.2f",p.getBillAmount(amount));
			break;
		}
		case 2:
		{
			System.out.println("Enter The Name");
			String name = s.nextLine();
			System.out.println("Enter The Age");
			Integer age =Integer.valueOf(chose) s.nex();
			System.out.println("Enter The Address");
			String address = s.nextLine();
			System.out.println("Enter The Mobile Number");
			String mobileNumber = s.nextLine();
			System.out.println("Enter The Purchased Amount");
			double amount = s.nextDouble();
			SeniorCitizenCustomer p = new SeniorCitizenCustomer(name, address, age, mobileNumber);
			p.displayCustomer();
			System.out.format("Your bill amount is Rs %.1f. Your bill amount is discount under privilege customer",amount);
			System.out.format("You have to pay Rs %.2f",p.getBillAmount(amount));
			break;
		}
			

		default:
		{
			System.out.println("Invalid Customer Type");
			break;
		}
			
		}

	}

}