zergling
15-08-2007, 23:15
Ciao a tutti,
Apro questo post perche avrei esigenza di interrompere il programma quando l'utente per sbaglio iserisce una lettera oppure una lettare e/o un numero allo stesso momento.
Esempio
Insert the cost of the pencil:
invece di mettere 5 metto 5saf
Questo e' il mio codice.
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{
const int pencils = 200;
double pencils_cost;
double tot_pencils_cost;
int year;
double rate_inflation;
cout << "Programmer: ZerglinG" << endl;
while ( pencils == 200 )
{
cout << endl << "Insert the cost of the pencil: $";
cin >> pencils_cost;
cout << endl << "Insert the current year: ";
cin >> year;
cout << endl << "Insert the inflation rate: ";
cin >> rate_inflation;
rate_inflation = rate_inflation / 100;
tot_pencils_cost = pencils_cost * pencils * rate_inflation;
cout << endl << "The estimate cost of 200 pencils is: $" << tot_pencils_cost;
cout << endl;
}
return 0;
}
Ciao e grazie in anticipo
Apro questo post perche avrei esigenza di interrompere il programma quando l'utente per sbaglio iserisce una lettera oppure una lettare e/o un numero allo stesso momento.
Esempio
Insert the cost of the pencil:
invece di mettere 5 metto 5saf
Questo e' il mio codice.
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{
const int pencils = 200;
double pencils_cost;
double tot_pencils_cost;
int year;
double rate_inflation;
cout << "Programmer: ZerglinG" << endl;
while ( pencils == 200 )
{
cout << endl << "Insert the cost of the pencil: $";
cin >> pencils_cost;
cout << endl << "Insert the current year: ";
cin >> year;
cout << endl << "Insert the inflation rate: ";
cin >> rate_inflation;
rate_inflation = rate_inflation / 100;
tot_pencils_cost = pencils_cost * pencils * rate_inflation;
cout << endl << "The estimate cost of 200 pencils is: $" << tot_pencils_cost;
cout << endl;
}
return 0;
}
Ciao e grazie in anticipo