I have the following code that calculates how much it costs to talk on the phone during the day evening and weekends for two plans. However the code malfunctions! What am I missing or need to add? Thank you for your help!
Code:#include <iostream>using namespace std; int main () { int x; int y; int z; cout<<"Number of daytime minutes?: "; cin>>x; cout<<"Number of evening minutes?: "; cin>>y; cout<<"Number of weekend minutes?: "; cin>>z; // Do i need to do this?! //int a; //int s; //int d; //int totalw; // //int f; //int g; //int h; //int totalq; if(x>=100) int a=x*25; if(y>=1) int s=y*15; if(z>=1) int d=z*20; if(x>=100) int totalw=a+s+d; else int totalw=s+d; if(x>=250) int f=x*45; if(y>=1) int g=y*35; if(z>=1) int h=z*25; if(x>=250) int totalq=f+g+h; else int totalq=g+h; cout<<"Plan A will cost "<<totalq<<" cents."<<endl; cout<<"Plan B will cost "<<totalw<<" cents."<<endl; if(totalq>totalw) cout<<"Plan B is cheapest."<<endl; else cout<<"Plan A is cheapest."<<endl; if(totalq==totalw) cout<<"Plan A and B are the same price."<<endl; }


1Thanks
LinkBack URL
About LinkBacks

