179k views
0 votes
Write C++ code to handle the following tasks. Students buy lab manuals for three subjects PF, DB, and Java. You have to input the quantity of PF, DB, and Java to be purchased by the student, also input the selling price of PF, DB, and Java lab manuals. After that, input whether the student is from BIIT or not. If the user enters "b" (not case sensitive), it means the student is from BIIT; otherwise, the student is not from BIIT. Provide a 20% discount to BIIT students. Students from other institutes are provided a 5% discount if the bill exceeds 30,000. Display the bill without discount, discount amount, and the bill after discount.

a) Input quantity and selling prices for PF, DB, and Java lab manuals
b) Determine if the student is from BIIT or not
c) Calculate the discount based on the conditions mentioned
d) Display the bill without discount, discount amount, and the bill after discount

1 Answer

5 votes

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.

User Alexmcfarlane
by
8.2k points