我怎样才能循环我的程序

How can i loop my program

我对 c++ 编程还很陌生,我已经制作了一个可以正常运行的税金计算器。但我不希望它循环,完成后不关闭。这是怎么做到的?

// ConsoleApplication5.cpp : 定义控制台应用程序的入口点。

代码

#include "stdafx.h"
#include "iostream"
int _tmain(int argc, _TCHAR* argv[])
{
cout << "Tax calculator" << endl;
cout << "The availible countries are: [S]weden, [N]orway, \n[F]inland, [R]ussia, [J]apan and [C]hina" << endl;
char country;
int amount;
cout << "Enter Country:" << endl;
cin >> country;
cout << "Enter Amount:" << endl;
cin >> amount;
if (country == 'S' || country == 's')
{
    const double swetax = 25;
    double total = 0;
    total += amount * swetax / 100.0;
    double totalstax = total + amount;
    cout << "The amount is" << totalstax << " SEK" << endl;
}
else if (country == 'N' || country == 'n')
{
    const double ntax = 25;
    double ntotal = 0;
    ntotal += amount * ntax / 100.0;
    double totalntax = amount + ntotal;
    cout << "The amount is" << totalntax << " NOK" << endl;
    cout << "Want to add tax to another value? (y/n)" << endl;
}
else if (country == 'F' || country == 'f')
{
    const double ftax = 24;
    double ftotal = 0;
    ftotal += amount * ftax / 100.0;
    double totalftax = amount + ftotal;
    cout << "The amount is" << totalftax << " EUR" << endl;
    cout << "Want to add tax to another value? (y/n)" << endl;
}
else if (country == 'R' || country == 'r')
{
    const double rtax = 18;
    double rtotal = 0;
    rtotal += amount * rtax / 100.0;
    double totalrtax = amount + rtotal;
    cout << "The amount is" << totalrtax << " RUB" << endl;
    cout << "Want to add tax to another value? (y/n)" << endl;
}
else if (country == 'J' || country == 'j')
{
    const double jtax = 8;
    double jtotal = 0;
    jtotal += amount * jtax / 100.0;
    double totaljtax = amount + jtotal;
    cout << "The amount is" << totaljtax << " JPY" << endl;
    cout << "Want to add tax to another value? (y/n)" << endl;
}
else if (country == 'C' || country == 'c')
{
    const double ctax = 17;
    double ctotal = 0;
    ctotal += amount * ctax / 100.0;
    double totalctax = amount + ctotal;
    cout << "The amount is" << totalctax << " CNY" << endl;
    cout << "Want to add tax to another value? (y/n)" << endl;
}
return 0;
}

也许你可以像下面那样做。

do{//While loop to loop back once done. You can also use while(1) instead do-while
    cout << "The availible countries are: [S]weden, [N]orway, \n[F]inland, [R]ussia, [J]apan and [C]hina;" << endl;
    cout<<" Z to break! \n";//Loop will break if user enter Z or z.
    .....//Your Code goes here
    else if (country == 'Z' || country == 'z')
       break;
}while(1)