|
-
April 26th, 2012, 08:58 PM
#1
Do While Issues
The following code seems to not work...after the first do while completes it goes on to the second one although the condition isn't met...i tried putting breaks in enclosing it in brackets...i don't know what else to do
Code:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int account_number;
int minutes;
char service;
double amount_due;
double day_min;
double night_min;
double regular;
double premium;
cout << fixed << showpoint;
cout << setprecision(2);
cout<<"Please enter your account number."<< endl;
cin>> account_number;
cout<<"Please enter account type.(R or r for regular service, P or p for premium service.)"<<endl;
cin>>service;
do
{
cout << "Enter the amount of minutes used." << endl;
cin >> minutes;
if (minutes <= 50)
{
amount_due=10.00;
cout << "Amount due:$" << amount_due << endl;
cout << "Account Number:" << account_number << endl;
cout << "Minutes used:" << minutes << "" <<endl;
break;
}
else ( minutes > 50 );
{
amount_due= ((minutes-50 ) * .20 + 10.00);
cout << "Amount due:$" << amount_due << endl;
cout << "Account Number:" << account_number << endl;
cout << "Minutes used:" << minutes << "" <<endl;
break;
}
}
while(service= 'r' || 'R' ) ;
// this is where is goes wrong
do
{
cout<< "How many minutes were used during the day?";
cin >> day_min;
cout<< "How many minutes were used during the night?";
cin >>night_min;
if(day_min <= 75)
{
amount_due=25.00;
cout << "Amount due for day minutes:$" << amount_due << endl;
cout << "Account Number:" << account_number << endl;
cout << " Day minutes used:" << day_min << "" <<endl;
break;
}
else if (day_min > 75)
{
amount_due = ((day_min - 75) *.10)+ 25.00;
cout << "Amount due for day minutes:$" << amount_due << endl;
cout << "Account Number:" << account_number << endl;
cout << " Day minutes used:" << day_min << "" <<endl;
break;
}
else if (night_min <= 100)
{
amount_due=25.00;
cout << "Amount due for night minutes:$" << amount_due << endl;
cout << "Account Number:" << account_number << endl;
cout << " Night minutes used:" << night_min << "" <<endl;
break;
}
else
{
amount_due=amount_due = ((night_min - 100) * .05)+ 25.00;
cout<<"Amount due for night minutes:$"<<amount_due<<endl;
cout << "Account Number:" << account_number << endl;
cout << " Night minutes used:" << night_min << "" <<endl;
break;
}
}
while ( service = 'p' || 'P');
cin.get();
cin.get();
return 0;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|