Programming & Computer Science Answers

C++ 9913
Python 5288
Java | JSP | JSF 3611
C 1680
C# 1362
Computer Networks 989
Algorithms 652
Databases | SQL | Oracle | MS Access 641
HTML/JavaScript Web Application 588
Other 537
Visual Basic 358
Assembler 209
Software Engineering 202
AJAX | JavaScript | HTML | PHP 166
MatLAB 150
MatLAB | Mathematica | MathCAD | Maple 124
Action Script | Flash | Flex | ColdFusion 112
UNIX/Linux Programming 89
Web Development 73
Excel 36
ASP | ASP.NET 23
Delphi | Pascal 21
Perl 16
Prolog 9
Functional Programming 9
MathCAD 5
Wolfram Mathematica 4
WPF 4
Ruby | Ruby on Rails 3
NodeJS Web Application 2

Questions answered by Experts: 26 876

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

In using C++ Inheritance, you need to

Create a game program using C++. The game specifications are the following:

1. The user has 3 types of player against a monster.

Master:

Life = 10

Super Power = Double attack (1 time)

Damage = Life to 0 if double attack was used

Healer:

Life = 10

Super Power = Restore life of warrior (1 time)

Damage = attack / 2 if healing power was used

Warrior:

Life = 10

No super power

2. Every attack of monster cause equal damage to player’s life. Deduct monster’s

attack to player’s life

3. Effect of player attack to monster depends on how player attack

4. Player’s super power (master and healer) can only be used once throughout the

game.

5. Player with 0 life is not allowed to attack

6. Monster has an initial life of 30

7. The game will continue until monster is defeated or all players are dead.


Required:

1. Use inheritance to create the program.

2. Display current life status in the given format (see testcase)

3. Ask user to choose a player ‘m’ for master, ‘h’ for healer and ‘w’ for warrior.

If user selects master or healer, ask user if they want use the super power if yes,

apply proper attack value to monster else perform a simple attack.

Note: They can only use each super power once.

Current life = previous life – attack

4. Generate random number from 1 to 6 as the attack value of both players and

monster.

Note: remove srand() on monster attack

5. At the end of a single round, display current status after the attack (see test

case)

6. Player with zero life is not allowed to attack thus inform user to choose another

player. Note: if user selects dead player, the round will still be the same.

7. Use looping statement to generate rounds of the game. The program will only

terminate if the total life of the team (life of master + life of Healer + life of warrior)

is equal or less than zero thus, monster won the game or the life of monster is

equal or less than zero.

8. Do not display negative life. If current life is less than 0 after the attack then

display zero



In from of C++ classes and object, one of the company which is Company ABC, an airline company is closely monitoring the distance between airplanes as they take-off on the same airport. You are asked to create a system that would calculate the distance between two planes A and B given the following plane attributes: Take-off Time, Speed (mi/hr), direction (north, east, west, south). Also, given the time where the navigation officer would like to check the distance.




In the form of Object-Oriented programming, create an equivalent program of the program from the first one. Create new source file and copy the given second program from. below


FIRST PROGRAM:

#include <iostream>

#include <cmath>

using namespace std;


void getArea(int length, int width, int radius) {

int recta;

float cira;

recta = length * width;

cira = 3.1416 * pow(radius, 2);

cout << "Area of Rectangle: " << recta << endl;

cout << "Area of Circle: " << cira << endl;

}

int main() {


int rectlength, rectwidth, cirradius;

cout << "Enter length of a Rectangle: ";

cin >> rectlength;

cout << "Enter width of a Rectangle: ";

cin >> rectwidth;

cout << "Enter radius of a Circle: ";

cin >> cirradius;


getArea(rectlength, rectwidth, cirradius);


return 0;

}



SECOND:#include <iostream>

#include <cmath>

using namespace std;


class Rectangle {

public:

int length, width;


double getArea(void) {

return length * width;

}

};


class Circle {

public:

int radius;


double getArea(void) {

return 3.1416 * pow(radius, 2);

}

};;


int main(){

Rectangle R;

Circle A;


cout << "Enter length of a Rectangle: ";

cin >> R.length;

cout << "Enter width of a Rectangle: ";

cin >> R.width;


cout << "Enter radius of a Circle: ";

cin >> A.radius;


cout << "Area of a Rectangle = " << R.getArea() << endl;

cout << "Area of a Circle = " << A.getArea() << endl;


}



In this program, we will display a menu to the user. The user can choose any option from the given menu. The

menu would be something like this:

Welcome to the World of Control Structures

• Press (A) to add two integers

• Press (S) to subtract two integers

• Press (M) to multiply two integers

• Press (E) to exit the program



We would like to implement the abstract data type called “Bag” that keeps track of bag of blobs. A bag has a maximum size Msize and supports insert, delete, IsEmpty, IsFull, and constructor/destructor operations.

Insert adds a new blob to the bag and Delete removes a blob from the bag. Assume blob is a record type. A bag of blobs can be implemented using an array A[1..Msize] of blob pointers. If there are k blobs in the bag then the entries A[1], ..., A[k] point to these blobs. The remaining entries of the array point to null.


TASK # 01: Write an efficient program that, given a color board (provided below), user has to fill up the color board with red ‘r’, green ‘g’ or blue ‘b’. you have to make sure that no color is repeated on connected positions. Ask user for the positions one by one for color filling. If the color filling is appropriate then increase the score, if it conflicts then decrease the score.

Your program should ask the user to enter his or her name before starting the game and show the score at the end. There should be a list of top 10 highest scorer and should be updated after every game. You have to:

·      Show the top scorer list on start of the game

·      Show the score and remaining tries after each try

·      Show the color board, total score and the rank of the user at the end of the game

In the following color board, a ‘0’ indicates not included position, an empty position indicates the place you have to fill colors on.


Write an efficient program that, given a color board (provided below), user has to fill up the color board with red ‘r’, green ‘g’ or blue ‘b’. you have to make sure that no color is repeated on connected positions. Ask user for the positions one by one for color filling. If the color filling is appropriate then increase the score, if it conflicts then decrease the score.

Your program should ask the user to enter his or her name before starting the game and show the score at the end. There should be a list of top 10 highest scorer and should be updated after every game. You have to:

·      Show the top scorer list on start of the game

·      Show the score and remaining tries after each try

·      Show the color board, total score and the rank of the user at the end of the game

In the following color board, a ‘0’ indicates not included position, an empty position indicates the place you have to fill colors on.



Write an efficient program that, given a color board (provided below), user has to fill up the color board with red ‘r’, green ‘g’ or blue ‘b’. you have to make sure that no color is repeated on connected positions. Ask user for the positions one by one for color filling. If the color filling is appropriate then increase the score, if it conflicts then decrease the score. 

Your program should ask the user to enter his or her name before starting the game and show the score at the end. There should be a list of top 10 highest scorer and should be updated after every game. You have to:

  • Show the top scorer list on start of the game 
  • Show the score and remaining tries after each try
  • Show the color board, total score and the rank of the user at the end of the game

In the following color board, a ‘0’ indicates not included position, an empty position indicates the place you have to fill colors on.



Write a program which takes 10 numbers from the user and store them in an array and find the average, Largest and smallest number in the array


Write a program that assigns Twenty random numbers to an array and counts all prime numbers entered by the user. The program finally displays a total number of primes in the array.


LATEST TUTORIALS
APPROVED BY CLIENTS