Write a program to prompt the user to enter the product to be bought. After accepting the product,
the user to provide the quantity to be bought also.
first answer right is the brainliest :D
Answers
Answer:
program that accepts two item’s weight (floating points' values ) and number of purchase (floating points' values) and calculate the average value of the items.
import java.util.*;
public class a
{
public static void main(String args[])
{
Scanner sc=new Scanner (System.in);
System.out.println("Electronic Store Product Menu");
System.out.println("Enter 1 for Laptop, 2 for Refrigerator, 3 for AC, 4 for Mobile");
System.out.println("Enter your choice:");
int choice = sc.nextInt();
System.out.println("enter quantity to be purchased");
int purchase = sc.nextInt();
if (choice == 1)
{
double discount = 5400 * purchase ;
double amount = 36000 * purchase ;
double amount_pay = amount - discount;
System.out.println("Bill Receipt");
System.out.println("Product ordered by you: Laptop");
System.out.println("Total amount (before discount):
"+amount);
System.out.println("Discount given: "+discount);
System.out.println("Amount Payable after adjusting discount:"+amount_pay);
}
else if (choice == 2)
{
double discount = 7500 * purchase ;
double amount = 26000 * purchase ;
double amount_pay = amount - discount;
System.out.println("Bill Receipt");
System.out.println("Product ordered by you: Refrigerator");
System.out.println("Total amount (before discount):
"+amount);
System.out.println("Discount given: "+discount);
System.out.println("Amount Payable after adjusting discount:"+amount_pay);
}
else if (choice == 3)
{
double discount = 6000 * purchase ;
double amount = 32000 * purchase ;
double amount_pay = amount - discount;
System.out.println("Bill Receipt");
System.out.println("Product ordered by you: AC");
System.out.println("Total amount (before discount):
"+amount);
System.out.println("Discount given: "+discount);
System.out.println("Amount Payable after adjusting discount:"+amount_pay);
}
else if (choice == 4)
{
double discount = 3200 * purchase ;
double amount = 17500 * purchase ;
double amountP = amount - discount;
System.out.println("Bill Receipt");
System.out.println("Product ordered by you: Mobile");
System.out.println("Total amount (before discount):
"+amount);
System.out.println("Discount given: "+discount);
System.out.println("Amount Payable after adjusting discount:"+amount_pay);
}
else
{
System.out.println("Bill Receipt");
System.out.println("Product ordered by you: None");
System.out.println("Total amount (before discount):
0");
System.out.println("Discount given: 0");
System.out.println("Amount Payable after adjusting discount: 0");
}
sc.close();
}
}