Please can someone check and compile this program and send me the the picture of
ID: 3761542 • Letter: P
Question
Please can someone check and compile this program and send me the the picture of the window(runing window) I do not have a C++ compile
#include <iostream>
#include<stdio.h>//standard input output
#include<stdlib.h>//standars library
//#include<string.h>
//#include<conio.h>
Int main ()
{
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;
Explanation / Answer
I think there are more than 2 programs, I have resolved all compilation errors
#include<iostream>
using namespace std;
//#include<string.h>
//#include<conio.h>
int main ()
{
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 0;
}
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;
}