Write a program to create a class which name is rectangle and also creat two data members Wich data type is float and calculate area of triangle which formula is(area=1/2 *base*height)
Improve the source code from class lecture (see the starter code) to display error messages if the user enters non numeric values. Also, the program needs to present the user with an error message if the initial deposit is more than their financial goal ($10,000).
Note: In order to get full credit for this exercise, you need to:
Sample Program Run:
Enter your initial deposit $:
Your initial $1800 needs 287 years to mature to $10020.6
Another Sample Program Run:
Enter your initial deposit $:
Invalid input!
Please enter your initial deposit (less than $10K):
Invalid input!
Please enter your initial deposit (less than $10K):
Invalid input!
Please enter your initial deposit (less than $10K):
Your initial $6123.88 needs 82 years to mature to $10001.4
Implement a class Sequence to store a sequence of non-negative integer values, and the length of the sequence. The class has the following private data members:
1. int length – the length of the sequence
2. int *pseq – a pointer to a dynamic integer array holding sequence of integer:
1.Sequence() – a default constructor that initializes length to 10 and store the sequence of all zeros in an array.
2. Sequence(int lengthVal, int n1=0,int n2=0,int n3=0, int n4=0, int n5=0, int n6=0, int n7=0, int n8=0, int n9=0, int n10=0) –
3. Sequence(Sequence &s) –
4. int getLength() – a getter for length
5. int* getSeq() – a getter for the sequence of numbers
6. void Sort(int n) –
7. int RemoveDuplicates() –
8. void Rotate(int steps) – a method that rotates the sequence elements clockwise for the
9. ~Sequence() – a destructor to deallocate the dynamically created array
Write a c++ program using while loop to display all the multiples of 5 from 100 to 50
Implement a structure, Car. The structure has the following data member:
1. int petrolLevel – that indicates the liters of petrol in the car’s petrol tank. PetrolLevel for
this car can only be in the range 0 – 45 liters.
The structure has the following member functions:
1. void setPetrolLevel(int petrolLevelVal) – a setter for petrol level, cannot set value greater
than 45.
2. int getPetrolLevel() – a getter for petrolLevel
3. Car() – a default constructor
4. Car(int petrolLevelVal) – a parametrized constructor
5. bool MoveCar(int distanceKM) – a function that takes an integer as an argument and
moves the car to the argument value which is in Km. Provided the petrol tank has enough
fuel. Successful movement of the car returns true otherwise returns false. Moving for
each km causes the petrolLevel to go low by one.
6. void Refill() – a function that refills the car tank to the maximum value of petrolLevel
7. bool isEmpty() – a function that tells whether the Petrol tank is Empty or not
2) Draw a flowchart for a program that will display a message “The number is 1” when the value of NUMBER is 1, “The number is 2” when then value of NUMBER is 2, “The number is not 1 or 2” when the value of NUMBER is not 1 or 2.
Mr. Tunan needs a directory that contains the following information.
(a) Name of a person
(b) Address
(c) Telephone Number
(d) Mobile Number
(e) Head of the family
He also needs a functionality to search the information of any person. Now develop a solution
using C++ for Tunan where you need to use a constructor to insert the information and a friend
function to show the output.
NAVANA LIMITED has imported 50 new TOYOTA COROLLA CROSS.
So, the Managing Director has instructed the concerned department to keep all the information
of these 50 cars for future development and statistics. For that reason, the GM of Sales and
Marketing department has marked out the mandatory information which are Customer_Name,
NID_Number, Purchase_Date, Engine_No, Registration_No. Also, they want some
functionality which are like inserting the information, showing all the sold list of Car and
Changing the ownership of the car. Now develop a solution using C++ to help NAVANA
LIMITED implementing this system following the below instructions.
Mr. Tunan needs a directory that contains the following information.
(a) Name of a person
(b) Address
(c) Telephone Number
(d) Mobile Number
(e) Head of the family
He also needs a functionality to search the information of any person. Now develop a solution
using C++ for Tunan where you need to use a constructor to insert the information and a friend
function to show the output.
Develop a program by creating an 'Employee' class having the following functions and print the
final salary.
1 - 'getInfo()' which takes the salary, number of hours of work per day of employee as parameters
2 - 'AddSal()' which adds $10 to the salary of the employee if it is less than $500.
3- 'AddWork()' which adds $5 to the salary of the employee if the number of hours of work per
day is more than 6 hours.