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

struct student

{

unsigned short studNum;

string name;

string course;

string yearLevel;

string section;

}


Write a program named question6c.cpp that demonstrates the use of the following functions. A C++ function named 

getName()prompts the user for two string values; first name and last name and return a combination of the two as 

one value. The second function getHours()calculate employee’s weekly pay, it must receive one argument, 

fullName, a stringvariable and a floatvalue for the rate. It must then prompt the user for hours worked for each 

day of the week, i.e. Monday – Friday and calculates the weekly pay. Employees who have worked more than 40 hours 

that week will receive a bonus of 10% and those who have worked less than 40 hour will receive 10% less pay for that 

week. 



Use the array ADT to compute the addition and subtraction of two polynomials.

The interface of your program must look like this one:

Enter the degree of polynomial for p(x) : 5

Enter the coefficient of x^0 : 0

Enter the coefficient of x^1 : 4

Enter the coefficient of x^2 : 5

Enter the coefficient of x^3 : 0

Enter the coefficient of x^4 : 6

Enter the coefficient of x^5 : 4

Enter the degree of polynomial for q(x) : 3

Enter the coefficient of x^0 : 3

Enter the coefficient of x^1 : -2

Enter the coefficient of x^2 : 3

Enter the coefficient of x^3 : 10

First Polynomial p(x) = 4x^5 + 6x^4 + 5x^2 + 4x

Second Polynomial q(x) = 10x^3 + 3x^2 – 2x + 3

p(x) + q(x) = 4x^5 + 6x^4 +10x^3 + 8x^2 + 2x + 3

p(x) – q(x) = 4x^5 + 6x^4 – 10x^3 + 2x^2 + 6x – 3

The numbers in Red are entered by the user.


Hint:

Use 1D array to store the polynomials:

For the above example, the polynomials will be stored like this:


Index 0 1 2 3 4 5

p(x) Coefficient 0 4 5 0 6 4


Index 0 1 2 3

q(x) Coefficient 3 -2 3 10


Use the array ADT to compute the addition and subtraction of two polynomials.

The interface of your program must look like this one:

Enter the degree of polynomial for p(x) : 5

Enter the coefficient of x^0 : 0

Enter the coefficient of x^1 : 4

Enter the coefficient of x^2 : 5

Enter the coefficient of x^3 : 0

Enter the coefficient of x^4 : 6

Enter the coefficient of x^5 : 4

Enter the degree of polynomial for q(x) : 3

Enter the coefficient of x^0 : 3

Enter the coefficient of x^1 : -2

Enter the coefficient of x^2 : 3

Enter the coefficient of x^3 : 10

First Polynomial p(x) = 4x^5 + 6x^4 + 5x^2 + 4x

Second Polynomial q(x) = 10x^3 + 3x^2 – 2x + 3

p(x) + q(x) = 4x^5 + 6x^4 +10x^3 + 8x^2 + 2x + 3

p(x) – q(x) = 4x^5 + 6x^4 – 10x^3 + 2x^2 + 6x – 3


Write a function to randomly delete a node in a doubly circular link list. The return type of this function

is void, and it will not accept any parameter. Then write a main() program to test your code. Here is

the sample output of the program.


Initial doubly link list is:

40 50 10 30 65 18 72

The computer has randomly chosen node number 5 to delete

The link list after deletion of node is

40 50 10 30 18 72


Write a main function that declares two rectangle object as follows:
The first name rect1 is created using the overridden default constructor.
The second named rect2 has a height of 5 and width of 10 assigned by the parameterized constructor.
Use setWidth and setHeight to assign rect1 a width of 100 and height of 25 respectively.
Call computeArea and computePerimeter for each rectangle object.
Call getArea and getPerimeter and display the area and perimeter of each rectangle.

given the value added tax is 15% of the cost of a product ,design an interface and write a program that accepts any cost of a product and calculates the value added tax given output


A car completes its journey in three parts. It travels the first X km of its journey at an average
speed of x_Speed m/s and the next Y km at an average speed of y_Speed km/h. The car completes the
last part of its journey at an average speed of z_Speed km/h in z_Minutes minutes. Here X, x_Speed, Y,
y_Speed, z_Speed, and z_Minutes are all variables whose values you will have to take as an input from the
user. Find the average speed for its entire journey, giving your answer in km/h.
à ƒ ƒ °  ‘ à ƒ ƒ °  ‘ Ãƒ ƒ ƒ °  ‘ ’à ƒ ƒ °  ‘ ’à ƒ ƒ °  ‘ ‘ =à ƒ ƒ °  ‘ ‘à ƒ ƒ °  ‘ –à ƒ ƒ °  ‘ à ƒ ƒ °  ‘ ¡Ãƒ ƒ ƒ °  ‘ ŽÃƒ ƒ ƒ °  ‘ ›Ãƒ ƒ ƒ °  ‘ Ãƒ ƒ ƒ °  ‘ ’ /à ƒ ƒ °  ‘ ¡Ãƒ ƒ ƒ °  ‘ –à ƒ ƒ °  ‘ šÃƒ ƒ ƒ °  ‘ ’
A passenger train travels at a speed of 72 km/h. A man on the passenger train observes a
goods train travelling at a speed of 54 km/h in the opposite direction. If the good train passes him in X
seconds, write a C++ function to find the length of the goods train.

A passenger train travels at a speed of 72 km/h. A man on the passenger train observes a

goods train travelling at a speed of 54 km/h in the opposite direction. If the good train passes him in X

seconds, write a C++ function to find the length of the goods train.


LATEST TUTORIALS
APPROVED BY CLIENTS