0% found this document useful (0 votes)
52 views4 pages

22 Mca 1075 Adid Baker

This Java program takes input from the user about customer name and product details including name, quantity, and price for 3 products. It calculates the total cost for each product and overall total. If the expiration date of product 3 is within 2 days, it applies a 30% discount on the total cost and prints the discounted total. Finally, it prints the bill with customer name and item-wise details of products and total cost.

Uploaded by

ORBIT GUY
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views4 pages

22 Mca 1075 Adid Baker

This Java program takes input from the user about customer name and product details including name, quantity, and price for 3 products. It calculates the total cost for each product and overall total. If the expiration date of product 3 is within 2 days, it applies a 30% discount on the total cost and prints the discounted total. Finally, it prints the bill with customer name and item-wise details of products and total cost.

Uploaded by

ORBIT GUY
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

EX NO: 1

PROGRAM TO GENERATE SUPERMARKET STOCK BILL

Code:

import java.time.LocalDate;

import java.util.Scanner;

public class SuperMarketBill {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

System.out.print("Enter customer name: ");

String customerName = scanner.nextLine();

System.out.print("Enter product-1 name: ");

String product1Name = scanner.nextLine();

System.out.print("Enter product-1 quantity: ");

int product1Quantity = scanner.nextInt();

System.out.print("Enter product-1 price: ");

double product1Price = scanner.nextDouble();

scanner.nextLine();

System.out.print("Enter product-2 name: ");

String product2Name = scanner.nextLine();

System.out.print("Enter product-2 quantity: ");

int product2Quantity = scanner.nextInt();

System.out.print("Enter product-2 price: ");

double product2Price = scanner.nextDouble();

scanner.nextLine();
System.out.print("Enter product-3 name: ");

String product3Name = scanner.nextLine();

System.out.print("Enter product-3 quantity: ");

int product3Quantity = scanner.nextInt();

System.out.print("Enter product-3 price: ");

double product3Price = scanner.nextDouble();

scanner.nextLine();

System.out.print("Enter expiration date (in form of yyy-mm-dd): ");

String expirationDateString = scanner.nextLine();

LocalDate expirationDate = LocalDate.parse(expirationDateString);

double product1TotalCost = product1Quantity * product1Price;

double product2TotalCost = product2Quantity * product2Price;

double product3TotalCost = product3Quantity * product3Price;

double totalCost = product1TotalCost + product2TotalCost + product3TotalCost;

if (expirationDate.isBefore(LocalDate.now().plusDays(2))) {

double discount = 0.3;

double discountedTotalCost = totalCost - (totalCost * discount);

totalCost = discountedTotalCost;

System.out.println("Product 3 is expired! Applying discount of " + (discount * 100) +


"%.");

System.out.println("Supermarket Bill");

System.out.println("------------------------------------------------------");
System.out.println("Customer Name: " + customerName);

System.out.println("Product-1 Name : " + product1Name);

System.out.println("Product-1 Quantity : " + product1Quantity);

System.out.println("Product-1 Price : " + product1Price);

System.out.println("Product Total Cost : " + product1TotalCost);

System.out.println("----------------------------");

System.out.println("Product-2 Name : " + product2Name);

System.out.println("Product-2 Quantity : " + product2Quantity);

System.out.println("Product-2 Price : " + product2Price);

System.out.println("Product Total Cost : " + product2TotalCost);

System.out.println("----------------------------");

System.out.println("Product-3 Name : " + product3Name);

System.out.println("Product-3 Quantity : " + product3Quantity);

System.out.println("Product-3 Price : " + product3Price);

System.out.println("Product Total Cost : " + product3TotalCost);

System.out.println("----------------------------");

System.out.println("Total Cost: " + totalCost);

OUTPUT:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy