Professional Documents
Culture Documents
IP Assignment FinalTerm
IP Assignment FinalTerm
IP Assignment FinalTerm
In main function create a variable of FlightTicket structure to book a flight using SetBooking
and use setFlightPath to set the locations. Finally, show the information of that flight ticket.
Note: Do not write any additional Setter and Getter Methods.
Create a method named inputStudentDetails() within the structure. This method should take
parameters to set the student's name, ID, Course_name, and mark. Create a method named
displayStudentDetails() within the structure. This method should display all the details of the
student. Print the student's name along with the unsatisfactory marks if the score is less than 55.
Write the student's name and an average mark if they received 55 to 79; otherwise, write an
outstanding mark and their name.
Part B: OOP [2 x 20=40]
1. Writea C++ Program that has a class named as Products and can store the
necessary information.
Member variables and
Instructions
Methods
productCode productName Use proper data types for member
price variables.
Create a Parameterized
Constructor
Create Setter and getter methods
void showProductsDetails() Display all the available information
Calculate and Return price with 15%
double getPriceWithVAT()
vat.
Write the main() function of the program. In the main(), create a product with
parameterized constructor and show the details of the product and price with VAT.
2. Output Tracing
#include<iostream>
using namespace std;
class Inventory{
private:
string ProductName;
double ProductPrice;
int quantity, flag = -1;
public:
static int ProductID;
static double InventoryPrice;
Inventory(){
cout<<"Current Price of Inventory: "<<InventoryPrice<<endl;}
Inventory(string PN, double pp, int qt){
flag=1; ProductName=PN;
ProductID+=10;
ProductPrice=pp; quantity=qt;
InventoryPrice=InventoryPrice+ProductPrice*qt;}
void RemoveProduct(int qt, double pp){
InventoryPrice=InventoryPrice-pp*qt; flag=0;}
void InventoryInfo(){
if(flag==0){
cout<<"Product Removed"<<endl;}
else if(flag>0){
cout<<"Product Added"<<endl;
cout<<"Product Name: "<<ProductName<<endl;
cout<<"Product ID: xY"<<ProductID<<endl;
cout<<"Product Price: "<<ProductPrice<<endl;
cout<<"Product Quantity: "<<quantity<<endl; }
}
~Inventory(){
if(InventoryPrice>2000){
cout<<"No Space Available"<<endl;}
else{
cout<<"Space Available"<<endl;} }
};
double Inventory::InventoryPrice=1200;
int Inventory::ProductID=101;
int main(){
Inventory P1; Inventory P2("Pringles",250,4);
P2.InventoryInfo();
Inventory P3;
P3.RemoveProduct(1,350);
P3.InventoryInfo();
}
int main() {
const int rows = 3;
const int cols = 3;
int array2D[rows][cols] = {{1, 2, 3},
{4, 5, 6},
{7, 8, 9}};
int maxElement = findMaxElement(array2D, rows, cols);
cout << "Maximum element in the 2D array: " << maxElement << endl;
return 0;
}