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 & Filtering

Using a class to represent the planet and its gravity, develop a program that outputs the user's weight on different planets.


  • The class's constructor should allow a planet to specified as a capitalized string. If the string is not a planet's name or is not capitalized, then the planet of EARTH should be assumed as the default value.
  • The default constructor for the class will create an object representing Earth. The class has a function called "convertWeight" that takes in a weight on earth as an argument and returns the name of the planet as well as the converted value reflecting weight on the given planet to console.
  • The program should output an error message and reprompt for input if the user does not input a correct planet name that is also capitalized.




Suppose you are an operating system designer and have been approached by the system administrator to help solve the recurring deadlock problem in your installation’s spooling system. What features might you incorporate into the operating system so that deadlocks in the spooling system can be resolved without losing the work (the system processing) that was underway or already performed by the deadlocked processes? Discuss using a short essay summary to explain how you go about solving deadlock problems.


Create a program that asks the user to enter the names of their last three employers. Output the names entered to confirm. Ask the user if the confirmation output is correct. If Yes, end the program. If No, then ask for the three names again.

 

Output:

This program will ask you to enter the company name of your last three employers.

Enter the company name:   [user types: 123 Corp]

Enter the company name:   [user types: 789 Corp]

Enter the company name:   [user types: Kendall Corp]

These are the company names you entered:

123 Corp

789 Corp

Kendall Corp

Are these three names correct (Y or N)?  [user types: n]

Enter the company name:   [user types: ABC Corp]

Enter the company name:   [user types: XYZ Corp]

Enter the company name:   [user types: Miami Corp]

These are the company names you entered:

ABC Corp

XYZ Corp

Miami Corp

Are these three names correct (Y or N)?  [user types: y]



This is similar to the exercise we did in class but with two changes: (1) Use doubles instead of ints; (2) The user will be providing the numbers. Just like the class exercise, output the sum, average, highest, and lowest of the user's numbers. 

 

Output:

This program will ask you to enter 5 numbers with decimal places.

It will then show you the total, average, largest number, and smallest number.

Enter a number:   [user types: 5.2]


Enter a number:   [user types: 9.8]


Enter a number:   [user types: 2.5]


Enter a number:   [user types: 17.5]


Enter a number:   [user types: 7.5]


Total: 42.5

Average: 8.5

Lowest: 2.5

Highest: 17.5


Let's start with an easy one. Create an array that stores 4 integers. Ask the user to enter any 4 numbers, one by one. Finally, output those numbers separated by three spaces.

 

Output:


This program will ask you to enter 4 numbers. It will then confirm your entries.

Enter a number:  [user types: 1]


Enter a number:  [user types: 2]


Enter a number:  [user types: 3]


Enter a number:  [user types: 4]


Your numbers: 1  2  3  4


All values in an array must be of the same data type.


A: True.

B: False.


The C++ compiler will return an error message if you use an array subscript that is beyond the boundaries of the array.


A: True.

B: False.


Observe the following code:

 

const int SIZE = 3;

int nums[SIZE] = {1, 2, 3};

for (int i = 0; i <= SIZE; i++) { 

  std::cout << nums[i];

}

 

What is wrong with this code?


A: You cannot use constants with array definitions.

B: The initialization list exceeds the size of the array.

C: Should be i = 1 because you need to start with the first array element.

D: Should be I < SIZE so that you don't access an array element that doesn't exist.


Observe the following code:

 

int nums[3] = {1, 2, 3};

std::cout << nums;

 

What will be output to the screen?


A: 1.

B: 3.

C: 123.

D: A memory address.


LATEST TUTORIALS
APPROVED BY CLIENTS