Advertisement
adventuretimeh

esercizio con if else

Oct 14th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  4. using namespace std;
  5.  
  6. int main(int argc, char** argv) {
  7.     char categoria;
  8.     float costo;
  9.    
  10.     cout << "Inserisci la categoria:\ncategoria P = pensionati, S = studenti, D = disoccupati):\t ";
  11.     cin >> categoria ;
  12.     cout << "prezzo biglietto:\t ";
  13.     cin >> costo;
  14.    
  15.     if (categoria == 'P')
  16.         costo -= costo * 0.1;
  17.     else if (categoria == 'S')
  18.         costo -= costo * 0.15;
  19.     else if (categoria == 'D')
  20.         costo -= costo * 0.25;
  21.     else
  22.         cout << "la categoria inserita non ha sconti\n" << endl;
  23.    
  24.     cout << "Pagherai : \n" << costo << endl;
  25.     system ("pause");
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement