Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A - Square (Perimeter and Area Computation) Write a C++ program that will allow

ID: 674433 • Letter: A

Question

A - Square (Perimeter and Area Computation)

Write a C++ program that will allow the user to input a side of a square and compute and output the square's perimeter and area. Please make your program user-friendly and format the output for easy readability. (If you don't know the formula to compute the area and perimeter of a square, Google it and find out ! )

B- Insurance Program

Write a program that asks for the user's age in years. If the user is under 35, the program will quote (output) an insurance rate of " 2.23 per hundred"; otherwise the rate will be "4.32 per hundred".) Note: No computation is required here, only the appropriate rate quote needs to be printed.

(Remember that if-else statements require program sample output to test each branch of the if-else statement so you will need to screen capture an output screen for each condition)

C - Grades Program

Write a C++ program that inputs a student's exam score and outputs a letter grade based on that score. You must use a "nested" if-else construction.

Here are the criteria:

If the score is greater than or equal to 90, print an "A". If it is greater than or equal to 80, print "B". If it is greater than or equal to 70, print "C". If it is greater than or equal to 60, print "D". Otherwise, print "F".

Please make your program user-friendly and format the output for easy readability.

(Remember that if-else statements require program sample output to test each branch of the if-else statements.)

Explanation / Answer

#include <iostream>
using namespace std;

void squareProgram()
{
int length;
int area;
int perimeter;

cout << " What is the side length of your square: ";
cin >> length;

area = (length * length);
perimeter = (length * 4);

cout << " You have a square with a perimeter of " << perimeter << " units and an area of " << area << " sq. units! ";
return;
}

void insuranceProgram()
{
int age;

cout << " What is your age (in years): ";
cin >> age;

if ( age < 35 )
{
cout << " Your quoted insurance rate is 2.23 per hundred. ";
} else {
cout << " Your quoted insurance rate is 4.32 per hundred. ";
}
return;
}

void gradesProgram()
{
int grade;

cout << " What is your grade: ";
cin >> grade;

if (grade >= 90) {
cout << " You earned an A, way to go! ";
} else if ( grade >= 80 )
{
cout << " You earned a B, solid work! ";
} else if ( grade >= 70 )
{
cout << " You earned a C, decent job. ";
} else if ( grade >= 60 )
{
cout << " You earned a D, not your best effort. ";
} else {
cout << " You earned an F, you need to hit the books. ";
}
return;
}

void blastoffProgram()
{

int number;

cout << " What is your number: ";
cin >> number;
cout << " ";

for ( ; number >= 0; number--)
{
cout << number << endl;
}

cout << "BlastOff!! ";
return;
}

void averagingProgram()
{
int numOfGrades;
int i;
int total = 0;
int average;
int currentGrade;

cout << " How many grades do you want averaged: ";
cin >> numOfGrades;
cout << " ";

for (i = 0 ; i < numOfGrades; i++)
{
cout << "Grade " << (i+1) << ": ";
cin >> currentGrade;
total += currentGrade;
}
average = (total/numOfGrades);
cout << " The average grade was a " << average << ". ";
return;
}

int main () {
int choice;

cout << "What would you like to do? 1: Run the square program? 2: Run the Insurance program? 3: Run the grades program? 4: Run the blast off program? 5: Run the Averaging program? I want to: ";
cin >> choice;

switch (choice) {
case 1:
squareProgram();
break;
case 2:
insuranceProgram();
break;
case 3:
gradesProgram();
break;
case 4:
blastoffProgram();
break;
case 5:
averagingProgram();
break;
default:
cout << " Sorry, you did not make a proper choice! ";
break;
}

return 0;
}