#include <iostream>
#include <windows.h>
#include <stdlib.h>
#include <math.h>
using namespace std;
void potenza();
void radice();
void calcolatrice();
void potenza()
{
float numero_pot, esponente, potenza=1;
int for_potenza;
cout << endl << " :: Numero: "; cin >> numero_pot;
cout << " :: Potenza: "; cin >> esponente;
for(for_potenza=0;for_potenza<esponente;for_potenza++);
potenza=potenza*numero_pot;
cout << endl << " :: Risultato: " << potenza << endl;
cout << endl << " :: Premi un tasto";
system("pause>nul");
}
void radice()
{
float radice, risultato_radice;
cout << endl << " :: Numero: "; cin >> radice;
risultato_radice=sqrt(radice);
cout << endl << " :: Risultato: " << risultato_radice << endl;
cout << endl << " :: Premi un tasto";
system("pause>nul");
}
void calcolatrice()
{
int primo_numero, secondo_numero, resto; char operazione; float risultato;
cout << endl << " :: Num1 Operazione Num2" << endl;
cout << " :: > "; cin >> primo_numero >> operazione >> secondo_numero;
switch(operazione) {
case '+':
cout << endl << " :: Risultato: ";
risultato=primo_numero+secondo_numero;
cout << endl << " :: Premi un tasto";
system("pause>nul");
break;
case '-':
cout << endl << " :: Risultato ";
risultato=primo_numero-secondo_numero;
cout << endl << " :: Premi un tasto";
system("pause>nul");
break;
case '*':
cout << endl << " :: Risultato ";
risultato=primo_numero*secondo_numero;
cout << endl << " :: Premi un tasto";
system("pause>nul");
break;
case '/':
cout << endl << " :: Risultato ";
risultato=primo_numero/secondo_numero;
cout << " :: Resto: ";
resto=primo_numero%secondo_numero;
cout << endl << " :: Premi un tasto";
system("pause>nul");
break;
}
}
int main()
{
int scelta_menu;
do {
system("cls");
cout << endl << " .:::::::::::::::::::::::::.";
cout << endl << " .: Calcolatrice C++ by SkirK :.";
cout << "\n" << " :::::::::::::::::::::::::::::::";
cout << endl << " :: 1 Calcolatrice";
cout << endl << " :: 2 Potenza";
cout << endl << " :: 3 Radice Quadrata";
cout << endl << " :: 4 Esci" << endl;
cout << endl << " :: > "; cin >> scelta_menu;
switch(scelta_menu) {
case 1:
calcolatrice();
break;
case 2:
potenza();
break;
case 3:
radice();
break;
}
}while(scelta_menu!=4);
return 0;
}