In an electronic product shop Diwali sale process has to be done. Get the details like customer name, Aadhar no, and product id. Write a menu-driven program in Java to implement the transaction process. Some customers are given special coupons and they don’t need to pay any amount for the purchase (Option 1). The customers who don’t have any coupons need to pay the amount (Option 2). If any other option (eg:press 3) is pressed exit. Implement this process by creating a class and by using Method overriding and inheritance. Use the constructor for initializing the number of customers and print the total cash collected and the pending amount with the product in the shop.The cash is collected based on the following criteria: AC (product id:11) /water heater (product id:12)Refrigerator (product id:13)/Washing Machine (product id:14)Installment 1170005000Installment 2100004000Installment 380004000 Input 1:Enter the option: 1(has coupon)Customer name: ReenaAadhar name : 78122009Product id: 13Enter the option: 2(no coupon)Customer name: BeenaAadhar name : 98765432Product id: 12Enter the installment number: 1Output1Reena7812200913Amount = 02Beena9876543212Paid amount = 17000Balance amount = 18000
Question
In an electronic product shop Diwali sale process has to be done. Get the details like customer name, Aadhar no, and product id. Write a menu-driven program in Java to implement the transaction process. Some customers are given special coupons and they don’t need to pay any amount for the purchase (Option 1). The customers who don’t have any coupons need to pay the amount (Option 2). If any other option (eg:press 3) is pressed exit. Implement this process by creating a class and by using Method overriding and inheritance. Use the constructor for initializing the number of customers and print the total cash collected and the pending amount with the product in the shop.The cash is collected based on the following criteria: AC (product id:11) /water heater (product id:12)Refrigerator (product id:13)/Washing Machine (product id:14)Installment 1170005000Installment 2100004000Installment 380004000 Input 1:Enter the option: 1(has coupon)Customer name: ReenaAadhar name : 78122009Product id: 13Enter the option: 2(no coupon)Customer name: BeenaAadhar name : 98765432Product id: 12Enter the installment number: 1Output1Reena7812200913Amount = 02Beena9876543212Paid amount = 17000Balance amount = 18000
Solution
Here is a simple Java program that implements the given scenario:
import java.util.Scanner;
class Customer {
String name;
int aadharNo;
int productId;
Customer(String name, int aadharNo, int productId) {
this.name = name;
this.aadharNo = aadharNo;
this.productId = productId;
}
}
class CouponCustomer extends Customer {
CouponCustomer(String name, int aadharNo, int productId) {
super(name, aadharNo, productId);
}
void transaction() {
System.out.println(name + " " + aadharNo + " " + productId + " Amount = 0");
}
}
class NonCouponCustomer extends Customer {
int installmentNo;
int paidAmount;
int balanceAmount;
NonCouponCustomer(String name, int aadharNo, int productId, int installmentNo) {
super(name, aadharNo, productId);
this.installmentNo = installmentNo;
if (installmentNo == 1) {
this.paidAmount = 17000;
this.balanceAmount = 18000;
} else if (installmentNo == 2) {
this.paidAmount = 10000;
this.balanceAmount = 4000;
} else {
this.paidAmount = 8000;
this.balanceAmount = 4000;
}
}
void transaction() {
System.out.println(name + " " + aadharNo + " " + productId + " Paid amount = " + paidAmount + " Balance amount = " + balanceAmount);
}
}
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the option: ");
int option = sc.nextInt();
if (option == 1) {
System.out.println("Customer name: ");
String name = sc.next();
System.out.println("Aadhar name : ");
int aadharNo = sc.nextInt();
System.out.println("Product id: ");
int productId = sc.nextInt();
CouponCustomer cc = new CouponCustomer(name, aadharNo, productId);
cc.transaction();
} else if (option == 2) {
System.out.println("Customer name: ");
String name = sc.next();
System.out.println("Aadhar name : ");
int aadharNo = sc.nextInt();
System.out.println("Product id: ");
int productId = sc.nextInt();
System.out.println("Enter the installment number: ");
int installmentNo = sc.nextInt();
NonCouponCustomer ncc = new NonCouponCustomer(name, aadharNo, productId, installmentNo);
ncc.transaction();
} else {
System.out.println("Exit");
}
}
}
This program first asks for the option. If the option is 1, it creates a CouponCustomer and performs the transaction. If the option is 2, it creates a NonCouponCustomer and performs the transaction. If any other option is entered, it exits. The transaction method is overridden in both CouponCustomer and NonCouponCustomer classes to provide the specific implementation for each type of customer.
Similar Questions
Write a program in Java using a method Discount( ), to calculate a single discount or a successive discount. Use overload methods Discount(int), Discount(int,int) and Discount(int,int,int) to calculate single discount and successive discount respectively. Calculate and display the amount to be paid by the customer after getting discounts on the printed price of an article.
Go through the situation given below and answer the questions that follow. Mahesh is the HR manager at a consultancy firm that has almost 1,000 employees. He is looking at options for Diwali gifts for the employees. For this purpose, he approaches his friend Avika, who works at the Warehousing and Logistics department of an electronic goods company. Given below is the mail that Avika writes to Rajeev, who is a part of the B2B department at her organisation. “Dear Rajeev, I am Avika from the Warehousing and Logistics team. I got your contact information from Nitish Roy, your manager. My friend Mahesh, who is the HR manager at a consultancy firm, wants to have a corporate tie-up with our organisation to procure Diwali gifts for his employees this season. He wants to purchase gifts for approximately 1,000 employees. He is interested in the S7 and S8 series of our products and would like to know the corporate rate for both these ranges. Regards,AvikaAssistant Manager, Warehousing and Logistics+91-98xxxxxx10”Question 2/2MandatoryUnderstand how to write an emailIn the email above, which of the following elements is missing?IntroductionMessageSalutationConclusion
For a movie ticket booking system, write a program in Java to implement the process. Some persons need First class seating system (Option1). Another option is Second class seating system (Option 2). Implement this process using Polymorphism and inheritance. In the ‘First’ class get the inputs like movie name, Theater Name, Show Date, and Number of Seats. If the date is 2022-11-20 print the price as 500 else print the price as 1000 for each seat. In the ‘Second’ class Get the inputs like movie name, Theater Name, Show Date, and Number of Seats. Cost of each ticket is Rs.200. If theater name is “mnbjhrbjbj” apply coupon code and reduce Rs.500 from actual price. Print all the details as a report.
Consider a ticket reservation system that allows users to book tickets for various destinations. Each ticket has details such as passenger name, destination, ticket price, and passenger age. The ticket prices are calculated based on the passenger's age, with children (age <= 12) receiving a 50% discount, senior citizens (age >= 60) receiving a 30% discount, and others paying the regular price. The system also tracks the confirmation status of each ticket.Design a Java program that implements this ticket reservation system. The program should prompt the user to input details for multiple tickets, including passenger name, destination, ticket price, and passenger age. It should then calculate and display the total amount of tickets booked for confirmed tickets alone, considering the discounted prices based on passenger age.Write the Java code for the ticket reservation system and demonstrate its functionality with a sample input/output scenario.Sample Input: 3 //No of tickets to book Ravi // NameDelhi // Destination2000 // Price70 // Age Manu // NameDelhi // Destination2000 // Price9 // Age Priya // NameDelhi // Destination2000 // Price40 // Ageconfirm // Do you want to confirm or cancel ticket 1? (confirm/cancel)cancel // Do you want to confirm or cancel this ticket 2? (confirm/cancel)confirm // Do you want to confirm or cancel this ticket 3? (confirm/cancel)Sample Output:3400.0 // Total Amount of Confirmed Tickets
Velan resort decides to automate their bookings. By automating they can easily enter the customer details, number of people visiting the resort, and based on the customer category they can calculate the booking price. So help the resort to do the automation using a Java programAssumptionPrice is in dollarsFor 1 adult 1000 per dayFor 1 child 650 per dayTake input from the user as a single string separating each field with a colon. <customer name>:<number of adults>:<number of child>:<number of days>Note:Customer category should be either "adult" or "child".If the number of adults is less than zero, print "Invalid input for number of adults"If the number of children is less than zero, print "Invalid input for number of children"If the number of days is less than or equal to zero, print "Invalid input for number of days"In the Sample Input / Output provided, the highlighted text in bold corresponds to the input given by the user, and the rest of the text represents the output.Ensure to follow the object-oriented specifications provided in the question description.Ensure to provide the names for classes, attributes, and methods as specified in the question description.Adhere to the code template, if provided.Do not use System.exit(0) to terminate the programSample Input/Output 1:Enter the customer detailsHarish:2:2:2Harish your booking is confirmed and the total cost is 6600Sample Input/Output 2:Enter the customer detailsGuru:1:0:0Invalid input for number of daysSample Input/Output 3:Ezhil:1:0:1Ezhil your booking is confirmed and the total cost is 1000
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.