Write a C++ program for the following specification: Create a class Fuzzy with two
data members: x of type integer and memx of type float. memx should range from 0 to 1. Implement the operator overloading for the operators: &, I and ~. i. Operator function for & should return the Fuzzy object with minimum memx, after checking the equality of data member x in both objects.
Sample Data:
f1 (10,0.5) f2= (10,0.2)
f1&f2= (10,0.2) ii. Operator function for should return the Fuzzy object with 1-memx..
Sample Data:
f2=(10,0.2) ~f2=(10,0.8)
Implement the appropriate member functions to get the input and print the output.
Note: In & operator overloading, if x is not equal, then return fuzzy object (0,0)
Imagine a tollbooth at a bridge. Cars passing by the booth are expected to pay a 50
cent toll. Mostly they do, but sometimes a car goes by without paying. T Model this tollbooth with a class called tollbooth. The two data items are a
type unsigned int to hold the total number of cars, and a type double to hold the total
amount of money collected. A constructor initializes both of these to 0. A member
function called payingcar() increments the car total and adds 0.50 to the cash total.
Another function, called nopaycar(), increments the car total but adds nothing to the
cash total. Finally, a member function called display() displays the two totals. Make
appropriate member functions const. Include a program to test this class. This program should allow the user to push one key to count a paying car, and another to count a nonpaying car. Pushing the ESC key should cause the program to print out the total cars and total cash and then exit.
Suppose we have 999 records of employees Emp1, Emp2, Emp5, Emp6 and so on up to Emp998 and Emp999 stored in a sequence. Hence, records are nothing but a row in the table. In the employee table, we want to insert new records Emp3 and Emp4 in the sequence, and once we have done insertion we need to update and retrieve the record efficiently to optimize the performance of a database by minimizing the access time when query is being executed.
You are required to solve the problem with the index sequential access method with pros and cons in the given scenario.
Create a class Time with data members – Hours(int), Minutes(int) and Seconds(int). Include two
constructors – (i) to initialize the data members to zero, and (ii) to initialize the data members with
the values passed as arguments. Include two member functions – (i) AddTime() to add two objects
passed as parameters and set the invoking object with this result (ii) DispTime() to display the time
in the format hh:mm:ss. The main() program should create two initialized Time objects and one that
is not initialized. Add the two initialized values leaving the result in the third Time object. Display the
values of the third object.
Create a class Book that contains instance variables like BKName, BKId and BKAuthor, a
parameterized constructor to initialize its instance variables, a method BKUpdateDetails(String name,
int id, String author), that accepts new values for name, Id and author as parameters and updates
the corresponding instance variable values of that object and another method BKDisplay() to display
the book details. Create a class BookDemo and provide main method for instantiate a Book object,
display the original book details, update its details with new values, and display the updated book
details
Design a class named Employee with following properties: name, employee ID and salary. Add
necessary constructors to initialize the data members. Add two methods, (1) Update(salary) to modify
the salary for the employee object and (2) Display() to print the employee details on screen. In main,
read an employee’s details from user, construct employee object from the user input, update
employee’s salary by calling appropriate function and display the employee’s details.
Create a class Vehicle with the following attributes: Registration Number, Model, Manufacturer,
Manufacturing Date, Engine number and Colour. Add a behaviour to change the colour and display
the updated Vehicle details.
Create the Class Book with the following attributes: Book ID, Title, Authors, Unit Price. Print the
current details of the book. Add a behaviour to modify the price and display the updated book details.
Display the total Amount to be paid for each Book, using unit price & 12% tax. Implement using OO
concepts.