Projekt Pentagon w c ++
Soo .. Piszę projekt pięciokąta dla mojej klasy c ++ i szczerze mówiąc nie robię teraz dobrze z powodu właściwej pracy i innych zajęć. Więc .. musimy stworzyć program pięciokąta, który będzie miał klasę Pentagonu i klasę menu. Zarządzałem pracą w Menu Class, ale nie jestem pewien, jak pracować z klasą Pentagonu. w każdym razie to, czego obecnie potrzebuję, to - zrobić właściwe równanie z pierwiastkami kwadratowymi.
Równanie dla znalezienia obszaru pięciokąta to:
A = s ^ 2 sqrt (z 25 + 10 sqrt (5)) / (over) 4
Jak mam to zrobić? Właśnie to mam obecnie w mojej klasie menu:
// ==================
#include "StdAfx.h"
#include <string>
#include <iostream>
#include <cmath>
// ==================
// ================
// Class Inclusions
// ================
#include "MenuClass.h"
#include "Math.h"
// ================
// ====================
using namespace std;
// ====================
// ============
// Constructors
// ============
// ===================
// Default Constructor
// ====================
Menu::Menu( void ) {
userMenuSelection = Quit;
} // Constructor Menu
// =====================
Menu::~Menu( void ) {
cout << "====================================" << endl;
} // Destructor ~Menu
// =====================
// ==============================
// Accessor Member-Function Get()
// ==========================
MenuChoices Menu::Get( ) {
return userMenuSelection;
} // Accessor Method Get
// ========================
// =============================
// Mutator Member-Function Set()
// ========================================
void Menu::Set( MenuChoices newValue ) {
userMenuSelection = newValue;
} // Mutator Method Set
// =======================
// ==========================
// Member-Function Display( )
// ==========================
void Menu::Display( ) {
cout << "======================================" << endl;
cout << " MENU SELECTION " << endl;
cout << "======================================" << endl;
cout << "1: Calculate the Perimeter of Pentagon" << endl;
cout << "2: Calculate the Area of Pentagon" << endl;
cout << "3: Quit" << endl;
cout << "======================================" << endl;
cout << endl;
} // Member-Function Display
// ============================
// =========================
// Member-Function QueryUser
// =========================
void Menu::QueryUser( ) {
int selection;
cout << "Enter Menu Selection: ";
cin >> selection;
switch (selection){
case 1: userMenuSelection = Perimeter;
break;
case 2: userMenuSelection = Area;
break;
case 3: userMenuSelection = Quit;
default: userMenuSelection = Quit;
} // switch
// ===========
cout << endl;
} // Method QueryUser()
// =======================
// =================
// Method Continue()
// ========================
bool Menu::Continue( ) {
return userMenuSelection != Quit;
} // Method Continue
// ====================
// ==============================
// Member-Function ProcessCommand
// ==============================
void Menu::ProcessCommand( ) {
int numberA; // Length of Sides
int numberB; // Area
if (userMenuSelection == Quit ){
cout << "Thank you for using this type of program. Have a nice day!" << endl;
}
else if (userMenuSelection != Quit) {
cout << "Please enter an integer value for the length of the sides: ";
cin >> numberA;
// ==============================
switch ( userMenuSelection ) {
case Perimeter:
cout << "Perimeter = " << (5 * numberA) << endl;
break;
case Area:
// Equation of Area:
// s^2*sqrt(25+10(sqrt(5)))/4
// 10*sqrt(5) = 22.36067977
double area;
area = sqrt(numberA(1+1));
return area;
///cout << "Area = " << ((numberA*numberA) * (5 + 22.36067977)) / 4 << endl;
//int param;
//int result;
//param = 1;
//cout << result = sqrt (param) << endl;
break;
default: cout << "Warning: error state encountered." << endl;
}
cout << endl;
}
}
// ========================
Proszę pomóż!