jag har typ gjort en bankkomatprogram eller nåt liknande men jag har lyckats med att fixa allt utom en sak:
men hom andvändaren skriver in fel en fel sedel, typ 49. då andvänder man ju default för att frågan ska komma om igen tills man skriver rätt. så jag undrar hur man gör då?
koden:
Visa spoiler
# include <iostream>
using namespace std;
int main(){
int bank=1000;
int sedel=0;
cout << " You got 1000 $ at your account " << endl << endl;
cout << " Please, enter how much money you wan´t to insert " << endl << endl;
cin >> sedel;
while (sedel != 50 || 100 || 500 || 1000)
switch(sedel)
{
case 50:
cout << " You have insert 50 " << endl << endl;
bank += 50;
break;
case 100:
cout << " You have insert 100 " << endl << endl;
bank += 100;
break;
case 500:
cout << " You have insert 500 " << endl << endl;
bank += 500;
break;
case 1000:
cout << " You have insert 1000 " << endl << endl;
bank += 1000;
break;
default:
cout << " You have insert a invalid sum " << " please try again " << endl << endl;
cout << " You still got " << bank << " at your account " << endl << endl;
}
cout << " know you got " << bank << " at your account " << endl << endl;
system("pause");
return 0;
}
using namespace std;
int main(){
int bank=1000;
int sedel=0;
cout << " You got 1000 $ at your account " << endl << endl;
cout << " Please, enter how much money you wan´t to insert " << endl << endl;
cin >> sedel;
while (sedel != 50 || 100 || 500 || 1000)
switch(sedel)
{
case 50:
cout << " You have insert 50 " << endl << endl;
bank += 50;
break;
case 100:
cout << " You have insert 100 " << endl << endl;
bank += 100;
break;
case 500:
cout << " You have insert 500 " << endl << endl;
bank += 500;
break;
case 1000:
cout << " You have insert 1000 " << endl << endl;
bank += 1000;
break;
default:
cout << " You have insert a invalid sum " << " please try again " << endl << endl;
cout << " You still got " << bank << " at your account " << endl << endl;
}
cout << " know you got " << bank << " at your account " << endl << endl;
system("pause");
return 0;
}
lol