Answer to Question #25833 in C++ for amber barnes

Question #25833
write the c++ code to display the message " Entry error" when the value in the units variable is less than or eqaul to 0. Otherwise, calculate the total owed by multiplying the units variable value by 5. Store the total owed in the toatal variable, and then display the total owed
1
Expert's answer
2013-03-12T12:51:00-0400
/*write the c++ code to display the message " Entry error" when the value in
the units variable is less than or equal to 0. Otherwise, calculate the
total owed by multiplying the units variable value by 5. Store the total
owed in the total variable, and then display the total owed*/

# include <iostream>

using namespace std;

int main(){

while(true){
int tot=0;
cout<<"Enter value:";
int n;
cin>>n;
if (n<=0) {cout<<"error\n";cout<<"Total:"<<tot<<endl; system("PAUSE");return 0;}
else{
tot+=n*5;


}
}

system("PAUSE");
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS