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

create a structures sterling that has three members pounds, siblings and pence all of type int. Write three functions .the first should get these three values separately from the user and return the value as a structure. The second should take two arguments of type string and return the added value as same type .the third function should take the structure as argument and convert it to decimal pounds (double type) and the double value .write a main problem that accept two sterlings inputs from the user as a separate values construct them as structure and add them and display the result in double type
Write a c++ program to implement the following . Assuming that a text file named first.text contains some text written into it .write a function named vowelwords (), that reads the file.txt and creates a new file named second.txt ,to contain those words from the file first.txt which start the lowercase vowel (a,e,i,o,u).

2.16: Diamond Pattern


Write a <span style="text-decoration-line: none;">program</span> that displays the following pattern:




*


***


*****


*******


*****


***


*


One acre of land is equivalent to 43,560 square feet. Write a program that calculates the number of acres in a tract of land with 389,767 square feet.




Assuming the ocean’s level is currently rising at about 1.5 millimeters per year, write a <span style="text-decoration-line: none;">program</span> that displays



  • The number of millimeters higher than the current level that the ocean’s level will be in 5 years,
  • The number of millimeters higher than the current level that the ocean’s level will be in 7 years,
  • The number of millimeters higher than the current level that the ocean’s level will be in 10 years,

1. Function Overloading : Compile time polymorphism: early binding: same function name with different types and number of arguments.

2. Virtual function: Run-time polymorphism: late binding: call function depending on where base pointer is pointing to.


Kamal would like to withdraw X Rs from an ATM. The cash machine will

only accept the transaction if X is a multiple of 100, and kamal's account balance has enough cash to

perform the withdrawal transaction. For each

successful withdrawal the bank charges 50 Rs. Calculate Kamal's account

balance after an attempted transaction.


Consider the definition of the following class:

class Sample

{

private:

  int x;

  double y;

public :

  Sample();

//Constructor 1

  Sample(int);

//Constructor 2

  Sample(int, int);

//Constructor 3

  Sample(int, double);

//Constructor 4

};


i. Write the

definition of the constructor 1 so that the private member variables are initialized

to 0.

ii. Write the

definition of the constructor 2 so that the private member variable x is

initialized according to the value of the parameter, and the private member

variable y is initialized to 0.

iii. Write the definition of the constructors 3 and 4 so that the private

member variables are initialized according to the values of the parameters


Consider the class declaration and main() function below. There are two errors in

the main() function. Name the errors and explain how to fix them, providing all the

code required to correct the errors.

class Game

{

public:

Game();

string getName();

int getLevel();

double getScore();

private:

string Name;

string Champion;

int Level

double Score;

};

int main()

{

Game sodoku, tetris[12];

.........(additional code)

double nScore = sodoku.Champion;

.........(additional code)

return 0;

cout << "The first tetris player is "

<< tetris.getName() << endl;

}


A book shop maintains the inventory of books that are being sold at their shop. The list includes details such as author, title, price, publisher and stock position. Whenever a customer wants a book, the sales person inputs the title and author and the system searches the list and displays whether it is available or not. If it is not, an appropriate message is displayed. If it is, then the system displays the book details and requests for the number of copies required. If the requested copies are available, the total cost of the requested copies is displayed; otherwise "Required copies not in stock" is displayed. Design a

system using a class called books with suitable member functions and constructors. Use new operator in constructors to allocate memory space required.
LATEST TUTORIALS
APPROVED BY CLIENTS