文盲求大神指点程序错误,使之得出正确结果。 [解决办法]
Quote: 引用:Quote: 引用:#include<iostream> //预编译命令using namespace std;int main() //主函数{ float ApplePrice=3.5; //对象1(苹果价格) float BananaPrice=4.2; //对象2(香蕉价格) float AppleWeight=0.0; //对象3(苹果重量) float BananaWeight=0.0; //对象4(香蕉重量) float Total=0.0; //对象5(总钱数) cout<<"请输入苹果的重量"<<endl; //提示信息 cin>>AppleWeight; //从键盘输入苹果的重量 cout<<"请输入香蕉的重量"<<endl; cin>>BananaWeight; Total=ApplePrice*AppleWeight+BananaPrice*BananaWeight; //计算应付款 cout<<"应付款"<<endl; system("pause"); return 0;}//除了这里,其他没有问题,测试了下cout<<"应付款"<< Total << endl;意思是就是把cout<<"应付款"<<endl; 改成cout<<"应付款"<< Total << endl;然后就没有其他错误了吗?
Quote: 引用:#include<iostream> //预编译命令using namespace std;int main() //主函数{ float ApplePrice=3.5; //对象1(苹果价格) float BananaPrice=4.2; //对象2(香蕉价格) float AppleWeight=0.0; //对象3(苹果重量) float BananaWeight=0.0; //对象4(香蕉重量) float Total=0.0; //对象5(总钱数) cout<<"请输入苹果的重量"<<endl; //提示信息 cin>>AppleWeight; //从键盘输入苹果的重量 cout<<"请输入香蕉的重量"<<endl; cin>>BananaWeight; Total=ApplePrice*AppleWeight+BananaPrice*BananaWeight; //计算应付款 cout<<"应付款"<<endl; system("pause"); return 0;}//除了这里,其他没有问题,测试了下cout<<"应付款"<< Total << endl;
#include<iostream> //预编译命令using namespace std;int main() //主函数{ float ApplePrice=3.5; //对象1(苹果价格) float BananaPrice=4.2; //对象2(香蕉价格) float AppleWeight=0.0; //对象3(苹果重量) float BananaWeight=0.0; //对象4(香蕉重量) float Total=0.0; //对象5(总钱数) cout<<"请输入苹果的重量"<<endl; //提示信息 cin>>AppleWeight; //从键盘输入苹果的重量 cout<<"请输入香蕉的重量"<<endl; cin>>BananaWeight; Total=ApplePrice*AppleWeight+BananaPrice*BananaWeight; //计算应付款 cout<<"应付款"<<endl; system("pause"); return 0;}
//除了这里,其他没有问题,测试了下cout<<"应付款"<< Total << endl;