C++ Answers

Questions answered by Experts: 9 913

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

Write a program to define a class Complex that will contain real and imaginary as the data members. Define appropriate constructors and a display functions. Overload the binary + and the * operator to add and multiply two complex numbers respectively.
Write a program to define two classes Alpha and Beta containing an integer each as data members. Define a function Sum() that will be a friend to both Alpha and Beta, That will take one object from each class as argument and return the sum of the data members of the argument objects.

Write a program that read an integer and display all its smallest factors. example if the input integer 120,then the output should be as follows: 2,2,2,3,5.


Write a function that determines whether an integer is a prime number.



Suppose you work for an employer that sells vehicles and your employer instructs you to design a program using the C++ language to determine the car that corresponds to the price that your program calculated. The price of the car is determined by adding three(3) prices: which are engine price, color price, and the price based on the color of the car. The engine price ranges between R500 000 – R2000000-00. The colour of the car ranges between R7000 – R10000

The price based on the power of the car ranges between R300 000 – R600 000. If the sum of the three(3) prices is between R700 000 – R1000000, the program must display that the car is in the range of a VW Golf 8 GTI. If the sum of the three(3) prices is between R1100000-1800000, the program must display that the car is in the range of a Mercedes Benz GLC63s. If the sum of the three(3) prices is between R1900 000 – R2500000, the program must display that the car is in a range of a BMW M8 challenger. DESIGN YOUR A PSEUDOCODE


Now, imagine your younger brother is working in a project with you. Both of you need to

solve negative number issue input by user. But you want to restrict information type

which can be send as error notification by your brother. So, write a program to handle the

scenario.


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)


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.


LATEST TUTORIALS
APPROVED BY CLIENTS