Week 7 (Lab PRGS)
Week 7 (Lab PRGS)
Test Summary
No. of Sections: 1
No. of Questions: 4
Total Duration: 30 min
Section 1 - Coding
Section Summary
No. of Questions: 4
Duration: 30 min
Additional Instructions:
None
Q1.
Problem Statement
Vamsi is a young and curious student who is eager to learn about finding the minimum
number among a set of integers and double values. He needs a program to find the
minimum number from a given set of values.
Help him solve the program by overloading the function named findMin.
Input Format
The first line of input consists of three space-separated integers.
The second line consists of three space-separated double values.
Output Format
The first line of output prints "Minimum integer: " followed by the minimum integer among
the given values.
The second line prints "Minimum double-point value: " followed by the minimum double-
point number among the given values, rounded off to two decimal places.
She wants to implement a UnitConverter class that contains two overloaded functions for
conversion:
1. double convert(double millimetres) - If the unit type is 1, convert the value to
centimetres.
2. double convert(int unitType, double value) - If the unit type is 2, convert the value to
kilometres.
You are creating a shopping cart for an e-commerce website. Implement overloaded
functions called calculateTotalPrice that can calculate the total price of different types of
items, such as a single item, multiple items, or items with discounts. Each overloaded
function should take the required parameters and return the calculated total price.
1. Calculate the total price for a single item without quantity or discounts.
2. Calculate the total price for multiple items in quantity without any discounts.
3. Calculate the total price for multiple items with quantity and a discount percentage.
Input Format
The user should enter an integer corresponding to the desired option (1, 2, 3, or 4).
If the choice is 1, the input consists of the price of the item, separated by a space.
If the choice is 2, the input consists of the price of the item and the quantity, separated by a
space.
If the choice is 3, the program consists of the price of the item, the quantity, and the
discount percentage, separated by a space.
If the choice is 4, the program exits.
If the choice is other than 1, 2, 3, or 4, it is considered an invalid choice.
Output Format
For the choices 1, 2, and 3, the output displays the calculated total price as a floating-point
number with two decimal places.
If the choice is 4, the program exits.
If the choice is invalid, the output displays "Invalid choice".
The output will be displayed on a new line.
You are designing a traffic simulator. Implement overloaded functions called calculateSpeed
that can calculate different speeds, such as the speed of a car, the speed of a train, and the
speed of a plane. Each overloaded function should take the required inputs and return the
calculated speed.
Formula:
speed = distance/time
speed = (distance/time) + acceleration*time
Example
Input:
100.5
10
5.5
6.6
Output:
10.05
65.05
76.05
Input Format
The first line of input consists of the distance (in meters) as a double value.
The second line of input consists of the time (in seconds) as a double value.
The third line of input consists of the acceleration (in m/s2) of the train as a double value.
The last line of input consists of the acceleration (in m/s2) of the plane as a double value.
Output Format
The first line of output prints the speed of the car (m/s) rounded off to two decimal places.
The second line of output prints the speed of the train (m/s) rounded off to two decimal
places.
The last line of output prints the speed of the plane (m/s) rounded off to two decimal places.
int main() {
int int1, int2, int3;
double double1, double2, double3;
return 0;
}
Q2Hidden Test CaseInputOutput
2
12000.00
0.01 km
Weightage - 10InputOutput
6
Invalid unit type!
Weightage - 10InputOutput
1
9000.00
900.00 cm
Weightage - 15InputOutput
2
18976.00
0.02 km
Weightage - 15InputOutput
1
7869.00
786.90 cm
Weightage - 25InputOutput
2
10000.00
0.01 km
Weightage - 25Sample InputSample Output
1
100.00
10.00 cm
Sample InputSample Output
2
541456.00
0.54 km
Sample InputSample Output
3
Invalid unit type!
Solution
#include <iostream>
#include <iomanip>
using namespace std;
class UnitConverter {
public:
double convert(double millimeters) {
return millimeters / 10.0;
}
int main() {
UnitConverter converter;
double value;
int unitType;
double result;
if (unitType == 1) {
result = converter.convert(value);
} else if (unitType == 2) {
result = converter.convert(unitType, value);
} else {
result = 0.0;
cout << "Invalid unit type!" ;
}
if (result != 0.0) {
if (unitType == 1) {
cout << fixed << setprecision(2) << result << " cm";
} else if (unitType == 2) {
cout << fixed << setprecision(2) << result << " km" ;
}
}
return 0;
}
Q3Hidden Test CaseInputOutput
1 150.50
1 190.50
2 500 6
4
150.50
190.50
3000.00
Weightage - 20InputOutput
2 504.50 7
6
1 200
4
3531.50
Invalid choice
200.00
Weightage - 20InputOutput
3 1547.50 2 10
2 2500 5
8
4
2785.50
12500.00
Invalid choice
Weightage - 25InputOutput
3 1310 13 10
2 457 3
3 600 57 50
2 256 3
1 2578
8
1 250
4
15327.00
1371.00
17100.00
768.00
2578.00
Invalid choice
250.00
Weightage - 35Sample InputSample Output
1 10.5
2 102.25 3
3 100 10 10
4
10.50
306.75
900.00
Sample InputSample Output
2 150 2
5
4
300.00
Invalid choice
Solution
#include <iostream>
#include <iomanip>
using namespace std;
double calculateTotalPrice(double price){
return price;
}
int main(){
int choice;
double price, total;
int quantity;
double discountPercentage;
do {
cin >> choice;
switch (choice) {
case 1:
cin >> price;
total = calculateTotalPrice(price);
cout << fixed << setprecision(2) << total << "\n";
break;
case 2:
cin >> price;
cin >> quantity;
total = calculateTotalPrice(price, quantity);
cout << fixed << setprecision(2) << total << "\n";
break;
case 3:
cin >> price;
cin >> quantity;
cin >> discountPercentage;
total = calculateTotalPrice(price, quantity, discountPercentage);
cout << fixed << setprecision(2) << total << "\n";
break;
case 4:
break;
default:
cout << "Invalid choice\n";
break;
}
} while (choice != 4);
return 0;
}
Q4Hidden Test CaseInputOutput
123.45
10.12
5.67
7.5
12.20
69.58
88.10
Weightage - 20InputOutput
567.89
20.23
10.11
15.5
28.07
232.60
341.64
Weightage - 20InputOutput
1090.12
30.34
15.16
15.15
35.93
495.88
495.58
Weightage - 25InputOutput
2134.56
50.56
25.18
50
42.22
1315.32
2570.22
Weightage - 35Sample InputSample Output
100.5
10.0
5.5
6.6
10.05
65.05
76.05
Solution
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
double distance;
double time;
double acceleration;
return 0;
}
Implement a Fraction class that represents a fraction with a numerator and a denominator.
Overload the '+' operator to add two fractions and return the result as a simplified fraction.
John is driving a car with an initial velocity (in m/s) that suddenly accelerates at a constant
rate (in m/s2) for a certain time (in seconds). He wants to write a program that calculates and
displays the final velocity of the car.
Help John calculate the final velocity by overloading the * operator in the Acceleration class.
Create a class Time to represent the departure time of a train, initialized with hours and
minutes. Overload the pre-increment operator ++ to advance the departure time by one
minute. Display the original and updated departure times.
Note: The time is represented in 24-hour format.
Input Format
The input consists of two space-separated integers, hours (h) and minutes (m) representing
the departure time of the train.
Output Format
The first line of output prints the original departure time and the second line prints the
updated departure time.
The time is printed in the format: [hours]h [minutes]m.
Maria is developing a program to manage student records, with a specific focus on weight
tracking. She has created a class named Student that represents student information and
allows for the incrementing (++) of a student's weight by 1 kg through operator overloading
with the friend function named operator.
class Fraction {
private:
int numerator;
int denominator;
public:
Fraction(int num = 0, int denom = 1) : numerator(num), denominator(denom) {}
int main() {
int num1, denom1, num2, denom2;
class Acceleration {
public:
float acceleration;
Acceleration(float val) {
acceleration = val;
}
Acceleration operator*(float t) {
Acceleration result(acceleration * t);
return result;
}
};
int main() {
float iv, av, t;
cin >> iv >> av >> t;
Acceleration obj(av);
Acceleration m = obj * t;
float a = m.acceleration;
float fv = iv + a;
class Time {
public:
int hours;
int minutes;
void display() {
cout << hours << "h " << minutes << "m";
}
Time operator++() {
minutes++;
if (minutes == 60) {
minutes = 0;
hours++;
}
if (hours == 24) {
hours = 0;
}
int main() {
int hr, min;
cin >> hr >> min;
t = ++t;
t.display();
return 0;
}
Q4Hidden Test CaseInputOutput
201
34.5
201 34.50
201 35.50
Weightage - 10InputOutput
202
45.768
202 45.77
202 46.77
Weightage - 10InputOutput
301
56.8970
301 56.90
301 57.90
Weightage - 15InputOutput
301
78.90
301 78.90
301 79.90
Weightage - 15InputOutput
701
89.836
701 89.84
701 90.84
Weightage - 25InputOutput
701
98.84
701 98.84
701 99.84
Weightage - 25Sample InputSample Output
101
34.8
101 34.80
101 35.80
Sample InputSample Output
103
78.987
103 78.99
103 79.99
Solution
#include <iostream>
#include <iomanip>
using namespace std;
class Student {
private:
int studentID;
double weight;
public:
Student(int id, double w) {
studentID = id;
weight = w;
}
void displayStudent() {
cout << studentID << " " << fixed << setprecision(2) << weight << endl;
}
int main() {
int studentID;
double initialWeight;
student.displayStudent();
++student;
student.displayStudent();
return 0;
}
VIT C_Structured and OOP_Lab 7_COD_Virtual Functions
Test Summary
No. of Sections: 1
No. of Questions: 4
Total Duration: 30 min
Section 1 - Coding
Section Summary
No. of Questions: 4
Duration: 30 min
Additional Instructions:
None
Q1.
Problem Statement
Renu works for a retail store that sells two types of items: wooden items and electronics.
The store needs a program to calculate the total amount for a customer's purchase based on
their choice of item type and the quantity or cost of the item(s).
Create a class called wooden that extends ItemType with a number of items and cost as its
private attributes. Obtain the data members and override the virtual function.
amount = number of items * cost
Create a class for electronics that extends ItemType with cost as its private attribute. Obtain
the data member and override the virtual function.
amount = 80% of the amount (20% discount)
Imagine you are creating a SleepTracker program that demonstrates the use of inheritance
and virtual functions. The program helps users analyze their sleep patterns, distinguishing
between weekday and weekend sleep durations.
Implement a base class called SleepTracker with attributes for bedtime and wakeup times
and virtual functions for input and duration calculation.
Create a program that manages student information and grades for two types of students:
Undergraduate (U) and Graduate (G). The program allows users to input a student's name,
roll number, and type ('U' for Undergraduate or 'G' for Graduate). Depending on the type,
the program calculates and displays the total grade for the student.
Virtual Functions
virtual void inputGrades(): Handles grade input.
virtual void calculateGrade(): Calculates and displays the total grade.
The first line of output should display "Name: " followed by the student's name.
The second line of output should display "Roll Number: " followed by the student's roll
number.
The third line of output should display "Total Grade: " followed by the calculated average
grade.
0 ≤ grades ≤ 100
Sample Input Sample Output
John
12345
U
80
90
Name: John
Roll Number: 12345
Total Grade: 85
Sample Input Sample Output
Alice
67890
G
85
92
Name: Alice
Roll Number: 67890
Total Grade: 88
Time Limit: - ms Memory Limit: - kb Code Size: - kb
Q4.
Problem Statement
Sharon is working on a population growth analysis program. She is studying how populations
change over time.
She wants to write a program that calculates the growth rate of a population based on its
initial and final sizes.
Help Sharon write a program that includes a base class Popul and a derived class Birth.
Popul has a virtual function calcRate() to initialize the initial and final sizes. Class Birth
inherits from Popul, overriding calcRate() to calculate the growth rate based on births.
Note: Growth Rate = (1000 * (final polulation - initial population) / initial population)
Input Format
The first line of input consists of an integer N, representing the initial population.
The second line consists of an integer P, representing the final population.
Output Format
The output prints a double value, representing the population growth rate, rounded off to
two decimal places.
class ItemType {
public:
virtual double calculateAmount() {
return 0.0; // Default implementation, can be overridden in derived classes
}
};
public:
void get() {
cin >> noOfItems >> cost;
}
double calculateAmount() {
return noOfItems * cost;
}
};
class Electronics : public ItemType {
double cost;
public:
void get() {
cin >> cost;
}
double calculateAmount() {
double discount = cost * 0.20;
return (cost - discount);
}
};
int main() {
int choice;
cin >> choice;
if (choice == 1) {
Wooden w;
w.get();
cout << fixed << setprecision(2) << w.calculateAmount();
} else if (choice == 2) {
Electronics e;
e.get();
cout << fixed << setprecision(2) << e.calculateAmount();
} else {
cout << "Invalid choice." << endl;
}
return 0;
}
Q2Hidden Test CaseInputOutput
19 19 06 06
21 07 11 15
Weekday: 10h 47m
Weekend: 14h 8m
User slept more on the weekend.
Weightage - 20InputOutput
21 30 06 45
20 30 05 45
Weekday: 9h 15m
Weekend: 9h 15m
User slept the same amount on weekdays and weekend.
Weightage - 20InputOutput
17 25 06 06
11 50 11 05
Weekday: 12h 41m
Weekend: 23h 15m
User slept more on the weekend.
Weightage - 10InputOutput
20 15 08 55
22 24 09 50
Weekday: 12h 40m
Weekend: 11h 26m
User slept more on weekdays.
Weightage - 25InputOutput
23 59 09 50
22 00 06 58
Weekday: 9h 51m
Weekend: 8h 58m
User slept more on weekdays.
Weightage - 25Sample InputSample Output
22 50 07 32
20 54 10 19
Weekday: 8h 42m
Weekend: 13h 25m
User slept more on the weekend.
Sample InputSample Output
22 00 06 05
23 00 06 05
Weekday: 8h 5m
Weekend: 7h 5m
User slept more on weekdays.
Sample InputSample Output
22 00 06 00
21 00 05 00
Weekday: 8h 0m
Weekend: 8h 0m
User slept the same amount on weekdays and weekend.
Solution
#include <iostream>
using namespace std;
class SleepTracker {
public:
int bh;
int bm;
int wh;
int wm;
void inputTime() {
cin >> bh >> bm >> wh >> wm;
}
virtual void calcDuration() {}
int getTotalMinutes() {
return (wh - bh) * 60 + wm - bm;
}
};
int main() {
WeekdaySleep wday;
WeekendSleep wend;
wday.inputTime();
wday.calcDuration();
wend.inputTime();
wend.calcDuration();
return 0;
}
Q3Hidden Test CaseInputOutput
Bob
54321
U
75
60
Name: Bob
Roll Number: 54321
Total Grade: 67
Weightage - 10InputOutput
Eva
98765
G
92
88
Name: Eva
Roll Number: 98765
Total Grade: 90
Weightage - 10InputOutput
Mia
45678
G
78
84
Name: Mia
Roll Number: 45678
Total Grade: 81
Weightage - 15InputOutput
Sophia
11223
U
96
78
Name: Sophia
Roll Number: 11223
Total Grade: 87
Weightage - 15InputOutput
Isabella
55555
U
79
91
Name: Isabella
Roll Number: 55555
Total Grade: 85
Weightage - 25InputOutput
Liam
77777
G
68
75
Name: Liam
Roll Number: 77777
Total Grade: 71
Weightage - 25Sample InputSample Output
John
12345
U
80
90
Name: John
Roll Number: 12345
Total Grade: 85
Sample InputSample Output
Alice
67890
G
85
92
Name: Alice
Roll Number: 67890
Total Grade: 88
Solution
#include <iostream>
#include <string>
class Student {
protected:
string name;
int rollNumber;
public:
Student(const string& name, int rollNumber) : name(name), rollNumber(rollNumber) {}
void displayDetails() {
cout << "Name: " << name << endl;
cout << "Roll Number: " << rollNumber << endl;
}
};
public:
UndergraduateStudent(const string& name, int rollNumber) : Student(name, rollNumber)
{}
void inputGrades() {
cin >> midtermGrade;
cin >> finalGrade;
}
void calculateGrade() {
int totalGrade = (midtermGrade + finalGrade) / 2;
cout << "Total Grade: " << totalGrade << endl;
}
};
public:
GraduateStudent(const string& name, int rollNumber) : Student(name, rollNumber) {}
void inputGrades() {
cin >> researchGrade;
cin >> presentationGrade;
}
void calculateGrade() {
int totalGrade = (researchGrade + presentationGrade) / 2;
cout << "Total Grade: " << totalGrade << endl;
}
};
int main() {
string name;
int rollNumber;
char studentType;
Student* student;
if (studentType == 'U') {
student = new UndergraduateStudent(name, rollNumber);
} else if (studentType == 'G') {
student = new GraduateStudent(name, rollNumber);
}
student->inputGrades();
student->displayDetails();
student->calculateGrade();
delete student;
return 0;
}
Q4Hidden Test CaseInputOutput
90
200
1222.22
Weightage - 10InputOutput
900
1000
111.11
Weightage - 10InputOutput
9000
10000
111.11
Weightage - 15InputOutput
5000
5678
135.60
Weightage - 15InputOutput
12000
100000
7333.33
Weightage - 25InputOutput
80000
100000
250.00
Weightage - 25Sample InputSample Output
100
1000
9000.00
Sample InputSample Output
456
768
684.21
Solution
#include <iostream>
#include <iomanip>
class Popul {
public:
virtual double calcRate(int initP, int finalP) {
if (initP <= 0 || finalP <= initP) {
return -1.0;
}
}
};
int main() {
int initP, finalP;
Birth growth;
return 0;
}
Rohith is designing a program that consists of a base class Expression with a pure virtual
function evaluate().
There are two derived classes PowerAB and PowerBA representing expressions of the form
ab and ba respectively, where a and b are real numbers. The program takes the values of a
and b as input and calculates and displays the power results for both types of expressions.
Note: Use the pow function from the math library to calculate the power value.
Input Format
The input consists of two space-separated double values a and b.
Output Format
The first line of output prints the value of ab as a double-value, rounded off to two decimal
places.
The second line prints the value of ba as a double-value, rounded off to two decimal places.
Design a program for a transport system operation. Create a base class Transport with a
pure virtual function named operate. Implement two derived classes, TransportA and
TransportB, which calculate and display the time taken to move between locations based on
the transport type.
The program takes input for the number of transport systems and their operations, then
outputs the time taken in seconds for each operation.
Write a program to calculate the total cost of a meal for a group of people.
The program has a base class, MenuItem, with an attribute price and a pure virtual function
calculatePrice().
Two derived classes, Appetizer and MainCourse, inherit from MenuItem. They implement
the pure virtual function to calculate the total cost based on the price of the item and the
number of persons.
For Example,
If there are 4 people in the group, and if the number of appetizer items is 3 and the number
of main course items is 4.
1. The appetizer prices are 44.25, 53.50, 75.99.
2. The main course prices are 48.99, 53.25, 86.75, 92.00.
The total cost is calculated by adding all the costs and multiplying the number of people.
1. For appetizers: (44.25 + 53.50 + 75.99) = 173.74
2. For main courses: (48.99 + 53.25 + 86.75 + 92.00) = 280.99
Total cost = (173.74 + 280.99) * 4 = 454.73 * 4 = 1818.92.
Input Format
The first line of input consists of an integer n, representing the number of persons dining.
The second line consists of two space-separated integers, N - the number of appetizer items
and M - the number of main course items.
The third line consists of N space-separated floating-point numbers, representing the prices
of the N appetizer items.
The fourth line consists of M space-separated floating-point numbers, representing the
prices of the M main course items.
Output Format
The output prints "Rs. X" where X is a float value, representing the the total cost of the
menu items for the specified number of persons, rounded off to two decimal places.
Imagine you are creating a hotel room pricing system with a class Hotel featuring a pure
virtual function calculatePrice() to calculate prices based on nights and guests. Derived
classes SingleRoom and DoubleRoom implement this function.
The program takes user input for nights and guests and then calculates and displays costs for
both room types.
Input Format
The first line of input consists of an integer n, representing the number of nights the guests
will use the room.
The second line consists of an integer p, representing the number of guests.
Output Format
The first line of output prints "Single Room Cost: " followed by an integer representing the
cost for the single room.
The second line prints "Double Room Cost: " followed by an integer representing the cost for
the double room.
class Expression {
public:
virtual double evaluate() = 0;
};
int main() {
double a, b;
cin >> a >> b;
class Transport {
public:
virtual void operate(int start, int dest) = 0;
};
int main() {
int numTransports;
cin >> numTransports;
return 0;
}
Q3Hidden Test CaseInputOutput
4
11
6.99
8.50
Rs. 61.96
Weightage - 10InputOutput
11
43
6.99 8.50 4.75 9.99
14.50 10.00 10.00
Rs. 712.03
Weightage - 20InputOutput
7
22
3.00 5.00
4.25 10.55
Rs. 159.60
Weightage - 20InputOutput
30
23
25.99 19.50
7.99 13.25 16.50
Rs. 2496.90
Weightage - 25InputOutput
15
55
4.99 6.25 8.50 3.75 9.99
14.25 7.99 5.50 12.75 10.00
Rs. 1259.55
Weightage - 25Sample InputSample Output
1
11
72.50
81.99
Rs. 154.49
Sample InputSample Output
4
34
44.25 53.50 75.99
48.99 53.25 86.75 92.00
Rs. 1818.92
Sample InputSample Output
11
55
5.99 4.75 3.99 7.50 12.25
6.75 15.99 3.25 10.00 10.00
Rs. 885.17
Solution
#include <iostream>
#include <iomanip>
class MenuItem {
public:
float price;
MenuItem(float itemPrice) {
price = itemPrice;
}
virtual float calculatePrice(int numPersons) = 0;
};
class Hotel {
public:
virtual int calculatePrice(int nights, int people) = 0;
};
if (nights > 5) {
cost = cost - (cost * 0.1);
}
else {
cost = cost + 15;
}
return cost;
}
};
if (nights > 5) {
cost = cost - (cost * 0.1);
}
else {
cost = cost + 15;
}
return cost;
}
};
int main() {
SingleRoom singleRoom;
DoubleRoom doubleRoom;
cout << "Single Room Cost: " << singleRoomCost << endl;
cout << "Double Room Cost: " << doubleRoomCost << endl;
return 0;
}
In the main method, prompt the user to enter the power rate of the appliance and the total
hours used then create the necessary objects and call the methods.
Input Format
The first line consists of the power rating of the fan and the total hours used separated by
space.
The second line consists of the power rating of Light and the total hours used separated by
space.
The third line consists of the power rating of the TV and the total hours used separated by
space.
Output Format
The output prints the bill amount.
Create a class wooden that extends ItemType with a number of items and cost as its private
attributes. Obtain the data members and override the virtual function.
amount = number of items*cost
Create a class electronics that extend ItemType with cost as its private attribute. Obtain the
data member and override the virtual function.
amount = 80% of the amount (20% discount)
class operationsBase
{
public:
virtual void addition() = 0;
virtual void subtraction() = 0;
virtual void multiplication() = 0;
virtual void division() = 0;
};
class operationsDerived : public operationsBase
{
int a,b;
public:
int get()
{
cin>>a>>b;
}
void addition()
{
cout<<a+b<<" ";
}
void subtraction()
{
cout<<a-b<<" ";
}
void multiplication()
{
cout<<a*b<<" ";
}
void division()
{
cout<<a/b<<" ";
}
};
int main()
{
operationsDerived od;
od.get();
od.addition();
od.subtraction();
od.multiplication();
od.division();
return 0;
}
Q3Hidden Test CaseInputOutput
AFKR
Score : 40
Weightage - 20InputOutput
GHkl
Score : 10
Weightage - 20InputOutput
QnUI
Score : 25
Weightage - 20InputOutput
phdm
Score : -20
Weightage - 20InputOutput
FbGH
Score : 25
Weightage - 20Sample InputSample Output
AFKR
Score : 40
Sample InputSample Output
AbDf
Score : 10
Solution
#include <iostream>
int main()
{
Derived dd;
cin>>dd.a>>dd.b>>dd.c>>dd.d;
dd.game();
return 0;
}
Q4Hidden Test CaseInputOutput
1
8 6520
52160.00
Weightage - 20InputOutput
2
15236
12188.80
Weightage - 20InputOutput
1
15 5000
75000.00
Weightage - 20InputOutput
2
85235
68188.00
Weightage - 20InputOutput
1
10 200
2000.00
Weightage - 20Sample InputSample Output
1
5 840
4200.00
Sample InputSample Output
2
1800
1440.00
Solution
#include<bits/stdc++.h>
using namespace std;
class ItemType
{
public:
virtual double calculateAmount() = 0;
};
};
int main()
{
int choice;
cin>>choice;
if(choice ==1)
{
wooden w;
w.get();
cout<<fixed<<setprecision(2)<<w.calculateAmount();
}
if(choice ==2)
{
electronics e;
e.get();
cout<<fixed<<setprecision(2)<<e.calculateAmount();
}