HWK For Week 01 and 02

Due Feb 4, 2019 @ 11:59 PM MSTt

VERY IMPORTANT

Below are the directions for how to register for MindTap. Please watch the video and look at the screenshots. You will need to access through Canvas and will have 2 weeks of free access. https://www.cengage.com/student-training/mindtap/canvas/ia-no

If you need addition support in getting registered or purchasing access to MindTap, below is the direct contact information for the Cengage Representative.

Laura Quinn, Laura.quinn@cengage.com , 720-554-9516 or Jamie McCallon, Jamie.McCallon@cengage.com, 806-535-4350

IF YOU CANNOT LOGON, BEFORE DOING IT MANUALLY AS INSTRUCTED BELOW, FIRST CALL UP THE PHONE NUMBERS ABOVE

If you still cannot get in, then:

STEP1. Code and compile your hwk in your IDE.

STEP2. Create a folder firstname_lastname_Hwk# Example Rory_Lewis_2.1

STEP3. Take a screenshot of your compiled code and the outcome

STEP4. Save the .cpp and the screenshot in your folder.

STEP5. Repeat steps 1 - 4 until you have completed all the HWKS for this session

STEP6. Create ANOTHER folder firstname_lastname_WEEK# Example Rory_Lewis_Week01

STEP7. Compress the folder

STEP8. Email the zipped folder to Zanyar Zohourianshahzadi zzohouri@uccs.edu

Programming Exercise 2-6

Due Feb 4, 2019 @ 11:59 PM MST

Consider the following program segment:

//include statement(s)

//using namespace statement

int main()

{

//variable declaration

//executable statements

//return statement

}

Write C++ statements that include the header files iostream and string.


Programming Exercise 2-9

Due Feb 4, 2019 @ 11:59 PM MST

Write a program that prompts the user to enter five test scores and then prints the average test score. Indicate the average test score by printing it to the terminal using the following format:

Your average test score is: X

(Assume that the test scores are decimal numbers.)

#include

using namespace std;

int main()

{

// Write your main here

return 0;

}


Programming Exercise 3-2

Due Feb 4, 2019 @ 11:59 PM MST

Consider the following program in which the statements are in the incorrect order.

Rearrange the statements so that the program prompts the user to input:

The height of the base of a cylinder

The radius of the base of a cylinder

The program then outputs:

The volume of the cylinder.

The surface area of the cylinder

Format the output to two decimal places.

#include

#include

int main()

{}

double height;

cout << "Volume of the cylinder = "

<< PI * pow(radius, 2.0) * height << endl;

cout << "Enter the height of the cylinder: ";

cin >> radius;

cout << endl;

return 0;

double radius;

cout << "Surface area: "

<< 2 * PI * radius * height + 2 * PI * pow(radius, 2.0)

<< endl;

cout << fixed << showpoint << setprecision(2);

cout << "Enter the radius of the base of the cylinder: ";

cin >> height;

cout << endl;

#include

const double PI = 3.14159;

using namespace std;


Programming Exercise 3-3

Due Feb 4, 2019 @ 11:59 PM MST

Write a program that prompts the user to enter the weight of a person in kilograms and outputs the equivalent weight in pounds. Output both the weights rounded to two decimal places. (Note that 1 kilogram equals 2.2 pounds.) Format your output with two decimal places.

#include

using namespace std;

int main()

{

// Write your main here

return 0;

}


Programming Exercise 3-6

Due Feb 4, 2019 @ 11:59 PM MST

Write a program that accepts as input the mass, in grams, and density, in grams per cubic centimeters, and outputs the volume of the object using the formula: volume = mass / density. Format your output to two decimal places.

/#include

using namespace std;

int main()

{

// Write your main here

return 0;

}


Programming Exercise 4-1

Due Feb 4, 2019 @ 11:59 PM MST

Write a program that prompts the user to input a number. The program should then output the number and a message saying whether the number is positive, negative, or zero.


Programming Exercise 4-3

Due Feb 4, 2019 @ 11:59 PM MST

Write a program that prompts the user to input an integer between 0 and 35. The prompt should say Enter an integer between 0 and 35:.

If the number is less than or equal to 9, the program should output the number; otherwise, it should output:

A for 10

B for 11

C for 12

. . .

and Z for 35.

(Hint: For numbers >= 10, calculate the ACSII value for the corresponding letter and convert it to a char using the cast operator, static_cast().)


Programming Exercise 4-4

Due Feb 4, 2019 @ 11:59 PM MST

The statements in the file main.cpp are in incorrect order.

Rearrange the statements so that they prompt the user to input:

The shape type (rectangle, circle, or cylinder)

The appropriate dimension of the shape.

Note: For grading purposes place the cylinder height statement before the radius statement.

The program then outputs the following information about the shape:

For a rectangle, it outputs the area and perimeter

For a circle, it outputs the area and circumference

For a cylinder, it outputs the volume and surface area.

After rearranging the statements, your program should be properly indented.

using namespace std;

#include

int main()

{

string shape;

double height;

#include

cout << "Enter the shape type: (rectangle, circle, cylinder) ";

cin >> shape;

cout << endl;

if (shape == "rectangle")

{

cout << "Area of the circle = "

<< PI * pow(radius, 2.0) << endl;

cout << "Circumference of the circle: "

<< 2 * PI * radius << endl;

cout << "Enter the height of the cylinder: ";

cin >> height;

cout << endl;

cout << "Enter the width of the rectangle: ";

cin >> width;

cout << endl;

cout << "Perimeter of the rectangle = "

<< 2 * (length + width) << endl;

double width;

}

cout << "Surface area of the cylinder: "

<< 2 * PI * radius * height + 2 * PI * pow(radius, 2.0)

<< endl;

}

else if (shape == "circle")

{

cout << "Enter the radius of the circle: ";

cin >> radius;

cout << endl;

cout << "Volume of the cylinder = "

<< PI * pow(radius, 2.0)* height << endl;

double length;

}

return 0;

else if (shape == "cylinder")

{

double radius;

cout << "Enter the length of the rectangle: ";

cin >> length;

cout << endl;

#include

cout << "Enter the radius of the base of the cylinder: ";

cin >> radius;

cout << endl;

const double PI = 3.1416;

cout << "Area of the rectangle = "

<< length * width << endl;

else

cout << "The program does not handle " << shape << endl;

cout << fixed << showpoint << setprecision(2);

#include

}


Programming Exercise 4-11

Due Feb 4, 2019 @ 11:59 PM MST

Write a program that implements the algorithm given in Example 1 - 3 (Chapter 1), which determines the monthly wages of a salesperson. The instructions for Example 1 - 3 have been posted below for your convenience.

EXAMPLE 1 - 3

Every salesperson has a base salary. The salesperson also receives a bonus at the end of each month, based on the following criteria: If the salesperson has been with the store for five years or less, the bonus is $10 for each year that he or she has worked there. If the salesperson has been with the store for more than five years, the bonus is $20 for each year that he or she has worked there. The salesperson can earn an additional bonus as follows: If the total sales made by the salesperson for the month are at least $5,000 but less than $10,000, he or she receives a 3% commission on the sale. If the total sales made by the salesperson for the month are at least $10,000, he or she receives a 6% commission on the sale.

To calculate a salesperson’s monthly paycheck, you need to know the base salary, the number of years that the salesperson has been with the company, and the total sales made by the salesperson for that month. Suppose baseSalary denotes the base salary,noOfServiceYears denotes the number of years that the salesperson has been with the store,bonus denotes the bonus, totalSales denotes the total sales made by the salesperson for the month, and additionalBonus denotes the additional bonus.