没办法计算运费,不知道怎么搞

明明有那个计算运费的代码,结果出来直接就是计算完成
#include
#include
using namespace std;
const int Password = 1234;
typedef struct Node
{
int no;
char owner[20];
float weight, money;
struct Node *next;
}Goods;
//验证管理员密码
int pass( )
{
int count, pw;
count = 0;
while (count < 3)
{
cout<<endl;
cout<<"请您输入操作密码:";
cin>>pw;
if (pw != Password)
{
count++;
cout<<"操作密码错误!"<<endl;
}
else
{
break;
}
}
if (count== 3)
{
count=0;
}
else{
count=1;
}
return count;
}
//操作菜单
int menu( )
{
int selected;
while (true)
{
cout<<endl;
cout<<"1.货物数据录入"<<endl;
cout<<"2.计算运费"<<endl;
cout<<"3.货物信息显示"<<endl;
cout<<"0. 退出程序"<<endl<<endl;
cout<<"请输入你的选择:(0~3) ";
cin>>selected;
if (selected > 3 ||
selected < 0)
{
cout<<"输入错误,请您重新输入!"<<endl;
}
else
{
break;
}
}
return selected;
}
void input(int &n, char *o,float &w)
{
cout<<endl;
cout << "请输入货物的编号:";
cin>>n;
cout << "请输入货物所有者:";
cin>>o;
cout << "请输入货物的重量:";
cin>>w;
}
float calCharge(float weight)
{
float money;
money = 0;
if (weight > 80)
{
money = (weight - 80) * 30;
}
if (weight >45)
{
money += (weight - 45) * 20;
}
if (weight >25)
{
money += (weight - 25) * 15;
}
if (weight >15)
{
money += (weight - 15) * 12;
}
return money;
}
int main()
{
int selected;
Goods *head, *s;
head = new Goods();
head->next= NULL;
cout<<"欢迎使用航空货物运费计算系统!"<<endl<<endl;
if (!pass())
{
cout<<"你已联系3次输入错误!系统即将退出…"<<endl;
system("pause");
return 0;
}
while (true)
{
switch (selected = menu())
{
case 1:
s = new Goods();
input(s->no, s->owner, s->weight);
s->next = head->next;
head->next = s;
break;
case 2:
s = head->next;
while (s)
{
s->money = calCharge(s->weight);
s = s->next;
}
cout << "计算完成"<<endl;
break;
case 3:
s = head->next;
printf("打印货物信息:\n");
printf("------------------------------------------------\n");
printf("编号 货物所有者 重量 运费\n");
while (s)
{
printf("%-10d%-16s%-10.2f%-10.2f\n",
s->no, s->owner, s->weight,s->money);
s = s->next;
}
printf("------------------------------------------------\n");
break;
default:
break;
}
if (selected==0)
{
cout<<"欢迎下次使用!再见…"<<endl;
break;
}
}
system("pause");
return;
}