Question

Assume that you are developing a billing software for a departmental store which sells electronic appliances,...

Assume that you are developing a billing software for a departmental store which sells electronic appliances, clothing, and toys. The store offers discounts on a festival occasion as below: a) 20 % discount on electronic appliances whose prices are greater than or equal to $100 b) 30 % discount on clothing if the price of a clothing item is greater than or equal to $50 c) All the toys greater than or equal to $20 are subject to 10% discount. All goods except toys are taxed at 8.5% of its price. Assume that the person at the checkout counter will be running your application. It has to take details of each item one by one until the check-out employee completes entering all the items in a customer’s cart. The employee enters the following data for each item: item code (int) item name (String) quantity (int) price (double) Category (1. Electronics, 2. Clothing, 3. Toys) Write a Java program to print itemized receipt along with total bill amount, taxes and savings. The output for the following test input is given below. Use the input to test code. Enter No of Items in the Cart: 3 Enter the item category as: 1. Electronics, 2. Clothing, 3. Toys: Enter the item code: 1 Enter the item Name: Toaster Enter the item price: 100 Enter the item Quantity: 1 Enter the item Category: 1 Toaster Item code : 1 qty :1 Price/unit : 100.0 Item discount : 20.0 Item total : 80.0 Enter the item code: 2 Enter the item Name: Jeans Enter the item price: 55 Enter the item Quantity: 1 Enter the item Category: 2 Jeans Item code : 2 qty :1 Price/unit : 55.0 Item discount : 16.5 Item total : 38.5 Enter the item code: 3 Enter the item Name: Softtoy Enter the item price: 20 Enter the item Quantity: 1 Enter the item Category: 3 Softtoy Item code : 3 qty :1 Price/unit : 20.0 Item discount : 2.0 Item total Order Total : 18.0 : 136.5 Sales Tax Total Bill amount : 146.5725 Total savings : 38.5

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/* PROGRAM */

/* import scanner class with util package */
import java.util.Scanner;
/* import package for decimal point selection to format decimal number */
import java.math.RoundingMode;
import java.text.DecimalFormat;
public class shop
{
public static void main(String args[])
{
    /* declare and initialize all variables */
       double price[]=new double[100];
       double unit_price[]=new double[100];
       double rg_price[]=new double[100];
       double s=0.0,tax=0.0,s1=0.0,discount=0.0;
       double stax[]=new double[100];
       int item_code[]=new int[100];
       int quantity[]=new int[100];
       int catagory[]=new int[100];
       double org_price;
       char ch;
       String item_name[]=new String[100];
       int i=0,j;   
       /* Application of scanner class */
       /* sc is the object of scanner class */
       /* sc is used to take input from console */
       Scanner sc=new Scanner(System.in);
       /* after point two decimal value and last digit will be 0 */
       DecimalFormat ob = new DecimalFormat("##.00");
       /* do while to take order one by one */
       do{
       System.out.println("Enter the item category as:");
       System.out.println("1. Electronics");
       System.out.println("2. Clothing");
       System.out.println("3. Toys");
       System.out.print("Enter the item code : ");
       item_code[i]=sc.nextInt();
       sc.nextLine();
       System.out.print("Enter the item Name : ");
       item_name[i]=sc.nextLine();
       System.out.print("Enter the quantity : ");
       quantity[i]=sc.nextInt();
       System.out.print("Enter the Price/unit : ");
       unit_price[i]=sc.nextDouble();
       price[i]=unit_price[i]*quantity[i];
      
       rg_price[i]=price[i];
       /* price after discount calculate */
       if(item_code[i]==1)
       {
       if(price[i]>=100)
       {
       discount=price[i]*20/100;
           System.out.println("Item discount : " +discount);
price[i]=price[i]-discount;
             
       }
}
       if(item_code[i]==2)
       {
       if(price[i]>=50)
       {
       discount=price[i]*30/100;
           price[i]=price[i]-discount;
       }
}
       if(item_code[i]==3)
       {
       if(price[i]>=20)
       {
       discount=price[i]*10/100;
           System.out.println("Item discount : " +discount);
price[i]=price[i]-discount;
       }
}
       /* All goods except toys are taxed at 8.5% of its price*/
       if(item_code[i]==1 || item_code[i]==2)
       {
       stax[i]=price[i]*8.5/100;
           price[i]= price[i]+ stax[i];
       }
       System.out.println();
       System.out.println("Actual purchase price : " +rg_price[i]);
       System.out.println("Total Discount : " + discount);
       if(item_code[i]==1 || item_code[i]==2)
       {
       System.out.println("Sales Tax : " + stax[i]);  
       }
       System.out.println("Total price : " + price[i]);
      
      
       i++;
       System.out.print("Want to continue [y/n] : ");
       ch=sc.next().charAt(0);
s=0.0;tax=0.0;s1=0.0;discount=0.0;         
       }
       while(ch=='y' || ch=='Y');
       /* if not continue display all */
       if(ch!='y' || ch!='Y')
       {
       System.out.println("\n");
       System.out.println("TOTAL BILLING DETAILS\n");
       for(j=0;j<i;j++)
       {
       System.out.println("Item Code : " + item_code[j]);
           System.out.println("Item Name : " + item_name[j]);
           System.out.println("Unit price : " + quantity[j]);
           System.out.println("Item Quantity: " + unit_price[j]);
           System.out.println("Item price : " + price[j]);
           System.out.println();
       }
       /* total tax and bill calculation */
       for(j=0;j<i;j++)
       {
       s=s+price[j];
           s1=s1+rg_price[j];
           if(item_code[j]==1 || item_code[j]==2)
           {
           tax=tax+stax[j];
           }
       }
       System.out.println("\n");
       System.out.println("Total Sales tax : " + ob.format(tax));
       System.out.println("Total Bill amount : " + ob.format(s));
       System.out.println("Total Saving amount : " + ob.format(s1-s));
       }
         
   }
}  

SCREEN SHOT

OUTPUT

Add a comment
Know the answer?
Add Answer to:
Assume that you are developing a billing software for a departmental store which sells electronic appliances,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • DESCRIPTION You have to design an e-commerce shopping cart. These require classes Item, Electronics, Food, Dress,...

    DESCRIPTION You have to design an e-commerce shopping cart. These require classes Item, Electronics, Food, Dress, Cart and Main. ITEM CLASS Your Item class should contain: Attributes (protected) String name - name of the Item double price - price of the item Methods (public) void setName(String n) - sets the name of Item void setPrice(double p) - sets the price of Item String getName() - retrieves name double getPrice() - retrieves price String formattedOutput() returns a string containing detail of...

  • Explain what the code is doing line from line explanations please or summarize lines with an explanation def displayCart(): #displays the cart function """displayCart function - dis...

    Explain what the code is doing line from line explanations please or summarize lines with an explanation def displayCart(): #displays the cart function """displayCart function - displays the items in the cart ---------------------------------------------------------------------""" import os os.system('clear') print("\n\nCart Contents:") print("Your selected items:", cart) def catMenu(): #function that displays the category menu """catMenu function - displays the categories user picks from ---------------------------------------------------------------------""" import os os.system('clear') print(""" 1 - Books 2 - Electronics 3 - Clothing d - display cart contents x -...

  • 11.11 LAB: Warm up: Online shopping cart (1) Build the ItemToPurchase class with the following specifications:...

    11.11 LAB: Warm up: Online shopping cart (1) Build the ItemToPurchase class with the following specifications: Attributes (6 pts) item_name (string) item_price (float) item_quantity (int) Default constructor (2 pt) Initializes item's name = "none", item's price = 0, item's quantity = 0 Method print_item_cost() Ex. of print_item_cost() output: Bottled Water 10 @ $1 = $10 (2) In the main section of your code, prompt the user for two items and create two objects of the ItemToPurchase class. (4 pts) Ex:...

  • Need three seperate files. ShoppingCartManager.java ShoppingCart.java ItemsToPurchase.java These are from part 1 what do you mean...

    Need three seperate files. ShoppingCartManager.java ShoppingCart.java ItemsToPurchase.java These are from part 1 what do you mean by deep study 7.25 LAB*: Program: Online shopping cart (Part 2) Note: Creating multiple Scanner objects for the same input stream yields unexpected behavior. Thus, good practice is to use a single Scanner object for reading input from System.in. That Scanner object can be passed as an argument to any methods that read input This program extends the earlier Online shopping cart program (Consider...

  • Can someone please help me with this Python code? Thank you in advance, Zybooks keeps giving me e...

    Can someone please help me with this Python code? Thank you in advance, Zybooks keeps giving me errors. Thanks in advance!! This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). (1) Extend the ItemToPurchase class to contain a new attribute. (2 pts) item_description (string) - Set to "none" in default constructor Implement the following method for the ItemToPurchase class. print_item_description() - Prints item_description attribute for an ItemToPurchase object. Has an ItemToPurchase parameter. Ex. of...

  • This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program).

    Ch 7 Program: Online shopping cart (continued) (Java)This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program).(1) Extend the ItemToPurchase class per the following specifications:Private fieldsstring itemDescription - Initialized in default constructor to "none"Parameterized constructor to assign item name, item description, item price, and item quantity (default values of 0). (1 pt)Public member methodssetDescription() mutator & getDescription() accessor (2 pts)printItemCost() - Outputs the item name followed by the quantity, price, and subtotalprintItemDescription() - Outputs the...

  • Zybooks 11.12 LAB*: Program: Online shopping cart (continued) Python 3 is the code needed and this...

    Zybooks 11.12 LAB*: Program: Online shopping cart (continued) Python 3 is the code needed and this is in Zybooks Existing Code # Type code for classes here class ItemToPurchase: def __init__(self, item_name="none", item_price=0, item_quantity=0): self.item_name = item_name self.item_price = item_price self.item_quantity = item_quantity # def __mul__(self): # print_item_cost = (self.item_quantity * self.item_price) # return '{} {} @ ${} = ${}' .format(self_item_name, self.item_quantity, self.item_price, print_item_cost) def print_item_cost(self): self.print_cost = (self.item_quantity * self.item_price) print(('{} {} @ ${} = ${}') .format(self.item_name, self.item_quantity, self.item_price,...

  • 11.12 LAB*: Program: Online shopping cart (continued) This program extends the earlier "Online shopping cart" pr...

    11.12 LAB*: Program: Online shopping cart (continued)This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program).(1) Extend the ItemToPurchase class to contain a new attribute. (2 pts)item_description (string) - Set to "none" in default constructorImplement the following method for the ItemToPurchase class.print_item_description() - Prints item_description attribute for an ItemToPurchase object. Has an ItemToPurchase parameter.Ex. of print_item_description() output:Bottled Water: Deer Park, 12 oz.(2) Build the ShoppingCart class with the following data attributes and related methods. Note: Some can be method stubs...

  • <Program 1: 50 points> software.cpp A software company sells a package that retails for $99. Quantity...

    <Program 1: 50 points> software.cpp A software company sells a package that retails for $99. Quantity discounts are given according to the following table. Quantity Discount 10-19 20% 20-49 30% 50-99 40% 100 or more 50% Write a program that asks for today's date (you MUST use cin >> date. Do not use getline(cin, date)), the company name and the quantity they wish to buy and computes the total cost of the purchase. If the user enters a negative value...

  • 7.11 LAB: Online shopping cart - Part 2 This program extends the earlier "Online shopping cart" program. (Consid...

    7.11 LAB: Online shopping cart - Part 2 This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). (1) Extend the ItemToPurchase namedtuple to contain a new attribute. (2 pts) item_description (string) - Set to "none" in the construct_item() function Implement the following function with an ItemToPurchase as a parameter. print_item_description() - Prints item_name and item_description attribute for an ItemToPurchase namedtuple. Has an ItemToPurchase parameter. Ex. of print_item_description() output: Bottled Water: Deer Park, 12 oz....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT