24.5k views
5 votes
Write C++ code to handle the following tasks involving purchasing lab manuals for three subjects (PF, DB, Java), inputting quantities and selling prices, providing discounts for BIIT students and others, and displaying the bill details.

User Deebster
by
7.1k points

1 Answer

7 votes

Final answer:

To handle the tasks of purchasing lab manuals for three subjects (PF, DB, Java), inputting quantities and selling prices, providing discounts for BIIT students and others, and displaying the bill details in C++ code, you can use a combination of functions, loops, and conditional statements. Here's an example code snippet to get you started: struct Subject { int quantity; double price; double amountSpent; double discount; }; int main() { Subject PF, DB, Java; // Input quantities and selling prices // Calculate amount spent // Apply discount based on BIIT student or not // Display bill details return 0; }

Step-by-step explanation:

To handle the tasks of purchasing lab manuals for three subjects (PF, DB, Java), inputting quantities and selling prices, providing discounts for BIIT students and others, and displaying the bill details in C++ code, you can use a combination of functions, loops, and conditional statements.

First, you can define a struct or class to hold the information for each subject, including the quantity, price, amount spent, and discount. Then, you can use a loop to input the quantities and selling prices for each subject, calculate the amount spent, and apply the discount based on whether the student is a BIIT student or not. Finally, you can display the bill details using printf or cout statements.

Here's an example code snippet to get you started:

#include <iostream>
using namespace std;

struct Subject {
int quantity;
double price;
double amountSpent;
double discount;
};

int main() {
Subject PF, DB, Java;
// Input quantities and selling prices
// Calculate amount spent
// Apply discount based on BIIT student or not
// Display bill details

return 0;
}

In this code snippet, you would fill in the input, calculation, discount, and display parts according to your specific requirements.

User Nelva
by
7.7k points