#include <iostream>
#include <windows.h>
#include <iomanip>
#include<ctime>
#include<conio.h>
#include<math.h>
#include<stdlib.h>
//libreria per SETPRECISION
using namespace std;
bool gotoxy(const WORD x, const WORD y);
void index (void);
void SetColor(unsigned short color);
int i,N,quot,val,k,sq,bonus;
float tot;
char c;
int main()
{
HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);
index();
if (N==0)
{
system("CLS");
signed char pr[] = "\nInserisci il primo numero: ";
signed char sc[] = "\nInserisci il secondo numero: ";
signed char rs[] = "\nRisultato: ";
signed char ln[] = "\n\n\n\n*****************************************************\n";
int a,x;
float b,c,d;
gotoxy(12,3);
SetColor(10);
cout <<"*****************************************************\n";
gotoxy(12,4);
cout <<"****************";
SetColor(12);
cout <<"DADDOSTYLE CALCULATOR";
SetColor(10);
cout <<"****************\n";
gotoxy(12,5);
cout <<"***********";
SetColor(12);
cout <<"FAI TUTTI I CALCOLI CHE VUOI!";
SetColor(10);
cout <<"*************\n";
gotoxy(12,6);
cout <<"*****";
SetColor (12);
cout <<"FORMULE-AREE-CALCOLI-RADICI QUADRATE-VOLUMI";
SetColor(10);
cout <<"*****\n";
gotoxy(0,8);
system("TITLE DaddoStyleCalculator");
system("PAUSE");
SetColor (8);
cout << "\n\nScegli un opzione:\n\n";
cout << "1)Addizione 5)Elevamento a Potenza\n";
cout << "2)Sottrazione 6)Radice Quadrata\n";
cout << "3)Moltiplicazione 7)Area Triangolo\n";
cout << "4)Divisione 8)Genera Numeri Casuali\n";
cout << "9)Area Rombo 10)Volume Cubo\n";
SetColor(12);
cout << "11)Superficie Laterale e Totale Cubo\n";
SetColor(10);
cout << "12)FORMULE VARIE\n\n";
SetColor(9);
cout << "SELEZIONE NUMERO: ";
cin >> a;
SetColor(3);
cin.clear();
switch(a)
{
case 1: {
while(true)
{
cout << ln;
cout << pr;
cin >> b;
cout << sc;
cin >> c;
d = b + c;
cout << rs << d;
getch();
}
}
break;
case 2: {
while(true)
{
cout << ln;
cout << pr;
cin >> b;
cout << sc;
cin >> c;
d = b - c;
cout << rs << d;
getch();
} }
break;
case 3: {
while(true)
{
cout << ln;
cout << pr;
cin >> b;
cout << sc;
cin >> c;
d = b * c;
cout << rs << d;
getch();
}
}
break;
case 4: {
while(true)
{
cout << ln;
cout << pr;
cin >> b;
cout << sc;
cin >> c;
d = b / c;
cout << rs<< d;
getch();
}
}
break;
case 5:
{
while(true)
{
cout << ln;
cout << "\nInserisci numero da elevare: ";
cin >> b;
cout << "\nInserisci l'esponente: ";
cin >> c;
d = pow(b,c);
cout << "\nRisultato: " << d;
getch();
}
}
break;
case 6:
{
while(true)
{
cout << ln;
cout << "\nInserisci il numero: ";
cin >> b;
d = sqrt(b);
cout << rs << d;
getch();
}
}
break;
case 7:
{ while(true)
{
cout << ln;
cout << "\nInserisci la base: ";
cin >> b;
cout << "\nInserisci l'altezza: ";
cin >> c;
d = b * c / 2;
cout << "\nArea: " << d;
getch();
}
}
break;
case 8:
{
cout << ln;
srand((unsigned)time(NULL));
while (true)
{
a = rand () % 20;
cout << a;
getchar();
}
} break;
case 9:
{ while(true)
{
cout << ln;
cout << "\nInserisci la diagonale Maggiore: ";
cin >> b;
cout << "\nInserisci la diagonale Minore: ";
cin >> c;
d = b * c / 2;
cout << "\nArea: " << d;
getch();
}
}
break;
case 10:
{ while(true)
{
cout << ln;
cout << "\nInserisci lo spigolo: ";
cin >> b;
c = b * b * b;
cout << "\nVolume: " << c;
getch();
}
}
break;
case 11:
{ while(true)
{
cout << ln;
cout << "\nInserisci lo spigolo: ";
cin >> b;
c = b * b * 4;
d = b * b * 6;
cout << "\nArea Laterale: " << c;
cout << "\nArea Totale: " << d;
getch();
}
}
break;
case 12:
{ while(true)
{
cout << "\nINTRODUZIONE\n\n";
cout << "\nA=area P=perimetro a=Apotema h=Altezza\n\n";
cout << "\nb=Base [3+5]/2=Tutta l'operazione contenuta nelle [ ] divisa per il numero dopo il simbolo/\n\n";
cout <<"\nl=Lato s=Spigolo V=Volume V'=Radice Quadrata\n";
cout <<"\nD=diagonale magg. d=Diagonale min.\n\n";
cout << "\n\n FINE INTRODUZIONE\n\n";
system("PAUSE");
cout <<"\n\nFORMULE POLIGONI\n\n";
cout << "\nTRIANGOLO\n\n";
cout << "\nP=l+l+l A=[bxh]/2\n";
cout << "\n b= [Ax2]/h h=[Ax2]/b\n\n\n";
cout << "\n\nFINE TRIANGOLO\n\n";
system("PAUSE");
cout <<"\n\nQUADRATO\n\n";
cout <<"\nP=lx4 A=bxh o lxl\n";
cout <<"\nl=P:4 l=V'A\n";
cout <<"\n\n FINE QUADRATO\n\n";
system("PAUSE");
cout <<"\n\nRETTANGOLO\n\n";
cout <<"\nP=bx2 + hx2 A=bxh\n";
cout <<"\nb= A:h h= A:b\n";
cout <<"\n\nFINE RETTANGOLO\n\n";
system("PAUSE");
cout <<"\n\nROMBO\n\n";
cout <<"\nA=[Dxd]/2 P=lx4\n";
cout <<"\n\nFINE ROMBO\n\n";
system("PAUSE");
cout <<"\n\nPENTAGONO\n\n";
cout <<"\nP=lx5 A=[Pxa]/2\n";
cout <<"\nl=A:a a=A:l\n";
cout <<"\n\nFINE PENTAGONO\n\n";
system("PAUSE");
cout <<"\n\nESAGONO\n\n";
cout <<"\nP=lx6 A=[Pxa]/2\n";
cout <<"\nl=A:a a=A:l\n";
cout <<"\n\nFINE ESAGONO\n\n";
system("PAUSE");
}
}
break;
default:
{
cout << ln;
cout << "\n\nScegli un opzione valida";
getch();
}
break;
}
return 1;
}
if (N==1)
{
system("CLS");
SetColor(14);
cout<<"Programma che calcola aree,perimetri di Poligoni e Solidi"<<endl;
SetColor(12);
cout<<"ATTENZIONE:Inserisci Solo i dati corretti quando richiesto!!"<<endl;
c=183;
SetColor(10);
cout<<"NOVIT"<<c<<": Formulario completo!!"<<endl;
gotoxy(0,5);
SetColor(15);
cout<<"PER ESEMPIO:";
gotoxy(0,7);
SetColor(7);
cout<<" Procedimento"<<endl;
cout<<"Area Quadrato: lxl"<<endl;
gotoxy(0,10);
cout<<"Nell'introduzione vengono spiegati i significati dei simboli";
gotoxy(0,12);
SetColor(8);
cout<<"Ovviamente ad ogni inserimento dovete premere 'INVIO'.";
gotoxy(0,14);
SetColor(6);
cout<<" Realizzato da Frainetti Davide"<<endl;
gotoxy(0,16);
cout<<" Il programma e' ancora in fase di aggiornamento";
gotoxy(0,18);
SetColor(12);
cout<<"Premi 'INVIO' per Tornare al menu'!.\n";
SetColor (0);
system("PAUSE");
system("CLS");
index(); //Ecco cosa ho inserito per farlo tornare all'index...solo che non ricomincia il ciclo...
getchar();
getchar();
}
getchar();
getchar();
}
bool gotoxy(const WORD x, const WORD y)
{
COORD posizione;
posizione.X = x;
posizione.Y = y;
return SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), posizione);
}
void index (void)
{
do
{
if (N>=2)
cout<<"\a";
system("CLS");
SetColor(11);
c=187;
gotoxy(79,0);
cout<<c;
c=201;
gotoxy(0,0);
cout<<c;
c=200;
gotoxy(0,24);
cout<<c;
c=188;
gotoxy(79,24);
cout<<c;
c=205;
gotoxy(1,0);
for (i=0;i<78;i++)
{
cout<<c;
}
gotoxy(1,24);
for (i=0;i<78;i++)
{
cout<<c;
}
c=186;
for (i=0;i<23;i++)
{
gotoxy(0,1+i);
cout<<c;
}
for (i=0;i<23;i++)
{
gotoxy(79,1+i);
cout<<c;
}
SetColor(10);
gotoxy(13,2);
cout<<"////// ////// // // /// ////// /////////";
gotoxy(12,3);
cout<<"// // // // // // /// // // // ";
gotoxy(11,4);
cout<<"// /// /////// // // /// // /// //// ";
gotoxy(10,5);
cout<<"// // // // // // /// // // // ";
gotoxy(9,6);
cout<<"/////// // // // /// //////// ////////// ";
gotoxy(9,8);
SetColor(2);
cout<<" Fai i tuoi Calcoli Veloci con un semplice click!!";
gotoxy(26,13);
SetColor(3);
cout<<"Inserisci '0' per continuare";
gotoxy(26,14);
cout<<"Inserisci '1' per Info\a\n";
c=205;
SetColor(8);
for (i=0;i<6;i++)
{
gotoxy(27+i,16);
cout<<c;
}
c=187;
gotoxy(32,16);
cout<<c;
c=186;
gotoxy(32,17);
cout<<c;
gotoxy(26,17);
cout<<c;
c=201;
gotoxy(26,16);
cout<<c;
c=200;
gotoxy(26,18);
cout<<c;
c=188;
gotoxy(32,18);
cout<<c;
c=205;
for (i=0;i<5;i++)
{
gotoxy(27+i,18);
cout<<c;
}
gotoxy(54,23);
c=184;
SetColor(15);
cout<<c<<" Copyright Daddo\n\n";
gotoxy(29,17);
SetColor(3);
cin>>N;
}
while(N>=2);
}
void SetColor(unsigned short color)
{
HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hCon,color);
}