Final answer:
The response provides a C++ code snippet to calculate the bill for purchasing lab manuals with discounts for BIIT students or others based on the bill amount.
Step-by-step explanation:
C++ Code for Lab Manual Purchase
The below C++ code snippet handles the process of purchasing lab manuals for three subjects: PF (Programming Fundamentals), DB (Databases), and Java. It considers quantity and selling price inputs, determines if the student is from BIIT, calculates the discount based on the provided conditions, and finally displays the billing details.
#include
#include
#include
using namespace std;
int main() {
// Variables
int qtyPF, qtyDB, qtyJava;
double pricePF, priceDB, priceJava;
string isBIIT;
double totalBill, discount, finalBill;
// Input quantities and selling prices
cout << "Enter quantity for PF: "; cin >> qtyPF;
cout << "Enter selling price for PF: "; cin >> pricePF;
cout << "Enter quantity for DB: "; cin >> qtyDB;
cout << "Enter selling price for DB: "; cin >> priceDB;
cout << "Enter quantity for Java: "; cin >> qtyJava;
cout << "Enter selling price for Java: "; cin >> priceJava;
// Calculate the total bill without discount
totalBill = (qtyPF * pricePF) + (qtyDB * priceDB) + (qtyJava * priceJava);
// Input and check if student is from BIIT
cout << "Is the student from BIIT? (b/B for yes, any other key for no): "; cin >> isBIIT;
// Determine the discount
if (isBIIT == "b" || isBIIT == "B") {
discount = totalBill * 0.20;
} else if (totalBill > 30000) {
discount = totalBill * 0.05;
} else {
discount = 0;
}
// Calculate the final bill after discount
finalBill = totalBill - discount;
// Display the bill details
cout << fixed << setprecision(2);
cout << "Total bill without discount: " << totalBill << endl;
cout << "Discount amount: " << discount << endl;
cout << "Total bill after discount: " << finalBill << endl;
return 0;
}
The code above prompts the user for the quantities and prices of the lab manuals for the three subjects. It then calculates the total bill, determines eligibility for discount based on the institute affiliation, computes the discount, and outputs the detailed billing information.