int i=0,j=0;
char choice;
string name;
string cdname;
double money;
CD myCd[100];
cout <<"*********************\n";
cout <<"This is the program \nto let you store \nthe CD information";
cout <<"\n*********************\n\n";
cout <<"1.Store the CD information\n";
cout <<"2.Display the CD information\n";
cout <<"3.Quit the program\n";
cin >> choice;
while (choice !='3'){
switch(choice){
case '1':
cout << "Please input the information of the following" << endl;
cout <<"Artist name:";
cin >> name;
cout <<"CD name:";
cin >> cdname;
cout <<"Cost:";
cin >> money;
myCd[i++].set_values(name,cdname,money);
system("cls");
cout << "You already enter " << i << " CD's information.\n" << endl;
break;
case '2':
for(j = 0; j < i; j++)
{
cout << " Details of" << "CD #" << ++j << ":" << endl;
myCd[--j].display();
}
break;
}
cout <<"1.store the CD information\n";
cout <<"2.display the CD information\n";
cout <<"3.quit\n";
cin >> choice;
}
cout << "Thanks to use this program" << endl;
system("pause");
return 0;
}作者: Super-Tomato 时间: 2009-12-17 10:40 PM