• Source
    1. #include <iostream>
    2.  
    3. using namespace std;
    4.  
    5. int main()
    6. {
    7. do
    8. {
    9.  
    10. cout << "****************************" << endl;
    11. cout << " CALCOLATRICE A DUE NUMERI " << endl;
    12. cout << "****************************" << endl;
    13. cout << "Seleziona una operazione " << endl;
    14. cout << "1. ADDIZIONE " << endl;
    15. cout << "2. SOTTRAZIONE " << endl;
    16. cout << "3. MOLTIPLICAZIONE " << endl;
    17. cout << "4. DIVISIONE " << endl;
    18.  
    19. int scelta;
    20. cin >> scelta;
    21.  
    22. if (scelta == 1)
    23. {
    24. cout << "Inserisci il primo numero"<<endl;
    25. int n1;
    26. cin >> n1;
    27. cout << "Inserisci il secondo numero"<<endl;
    28. int n2;
    29. cin >> n2;
    30. int somma = n1 + n2;
    31. cout << "La somma e' " << somma << endl;
    32. }
    33. else if (scelta == 2)
    34. {
    35. cout << "Inserisci il primo numero"<<endl;
    36. int n1;
    37. cin >> n1;
    38. cout << "Inserisci il secondo numero"<<endl;
    39. int n2;
    40. cin >> n2;
    41. int differenza = n1 - n2;
    42. cout << "La differenza e' " << differenza << endl;
    43. }
    44. else if (scelta == 3)
    45. {
    46. cout << "Inserisci il primo numero"<<endl;
    47. int n1;
    48. cin >> n1;
    49. cout << "Inserisci il secondo numero"<<endl;
    50. int n2;
    51. cin >> n2;
    52. int prodotto = n1 * n2;
    53. cout << "Il prodotto e' " << prodotto << endl;
    54. }
    55. else if (scelta == 4)
    56. {
    57. cout << "Inserisci il primo numero"<<endl;
    58. int n1;
    59. cin >> n1;
    60. cout << "Inserisci il secondo numero"<<endl;
    61. int n2;
    62. cin >> n2;
    63. double quoziente = n1 / n2;
    64. cout << "Il quoziente e' " << quoziente << endl;
    65. }
    66. else
    67. {
    68. cout << " operazione non ammessa"<<endl;
    69. }
    70. } while (true);
    71.  
    72.  
    73. }