Explore BrainMass

C++ programs

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

1 Create three arrays of 20 integers each. Fill in two arrays with data, leaving the third blank. From main, pass these three arrays into a function. Inside the function, add the value of each array element and store it in the third.
third_array[i] = second_array[i] + first_array[i]

Back in main, print out the value of every element in the third/sum array. Excellent output on this assignment might show something like:
Array 1 + Array 2 = Array 3
5 + 3 = 8
10 + 4 = 14

2. Design and run a program that takes a numerical score and outputs a letter grade. Specific numerical scores and letter grades are listed below:
90-100 = Grade A
80-89 = Grade B
70-79 = Grade C
60-69 = Grade D
0-59 = Grade F

In this program, create two void functions titled getScore and printGrade with an int argument. The function getScore should have a Reference parameter and printGrade should have a Value parameter.

The function getScore will prompt the user for the numerical score, get the input from the user, and print the numerical score. The function printGrade will calculate the course grade and print the course grade. (Be careful and note that the assignment requires you to input the grade into getScore and not directly into the main function.)

Do not forget to put in the proper prompts and appropriate output messages. (Note: This program is a natural for use of the switch command, but if?else structures will also work.)
3. Write a program that includes the following four steps:
Step 1.Create a structure with the name StudentRecord containing a Name stored as an array of 20 characters, an ID stored as an integer, and a GPA stored as a floating-point number. Create (instantiate) a variable from StudentRecord called TESCStudent.

Step 2. Assign the following values to the variable by assuming Name is SuperProgrammer, with an ID of 1234, and a GPA of 4.0.

Step 3. The program should print out on the screen that SuperProgrammer with an Identification number of 1234 has a 4.0 GPA. (Of course, your program needs to use the structure you defined in step 1.)

Step 4. Generalize the program so that you can input the student's name, ID, and GPA when the program is run. Please do not forget to include prompt statements in your program. Print out the user entered Name, ID, and GPA.

Make sure your program includes all four steps, not just steps 1 and 4.

4. Define a class called Plot that has private members of length and width. Include a constructor and a public function that calculates the area and the length of the boundary of the field. Use public functions in a program that computes and displays the area and the length of the boundary of the plot where the length and width are 7 and 9 respectively. Hint: The length of the boundary is 2 * (length + width).

© BrainMass Inc. brainmass.com October 25, 2018, 1:45 am ad1c9bdddf

Solution Summary

The programs are properly commented to make it easier for you to understand.

See Also This Related BrainMass Solution

C++ code block program: Converting pounds to stone

I need to write a program that will run in Code Blocks 10.05 that will:

Convert pounds (US) to Stone (UK)

- Take input from user

- Return ciphered answer to user

1 Pound = 0.0714285714 Stones

View Full Posting Details