Flowchart, create. #include #include using namespace std; double computeRate(int); double computeRate(int, string); int main() { int days; string mealPlan; string question; double rate = 0.0; cout << "How many days do you plan to stay? " << endl; cin >> days; cout << "Do you want a meal plan? Y or N: " << endl; cin >> question; if(question=="Y" || question == "y") { cout<<"Enter the meals code: "<> mealPlan; rate = computeRate(days,mealPlan ); } else { rate = computeRate(days); } // Figure out which arguments to pass to the computeRate() function and // then call the computeRate() function cout << "The rate for your stay is $" << rate << endl; return 0; } // End of main() function // Write computeRate functions here. double computeRate(int days) { return days * 99.99; } double computeRate(int days, string s) { if(s == "A") { return days * 169; } else { return days * 112; } }
Flowchart, create.
#include <iostream>
#include <string>
using namespace std;
double computeRate(int);
double computeRate(int, string);
int main()
{
int days;
string mealPlan;
string question;
double rate = 0.0;
cout << "How many days do you plan to stay? " << endl;
cin >> days;
cout << "Do you want a meal plan? Y or N: " << endl;
cin >> question;
if(question=="Y" || question == "y") {
cout<<"Enter the meals code: "<<endl;
cin >> mealPlan;
rate = computeRate(days,mealPlan );
} else {
rate = computeRate(days);
}
// Figure out which arguments to pass to the computeRate() function and
// then call the computeRate() function
cout << "The rate for your stay is $" << rate << endl;
return 0;
} // End of main() function
// Write computeRate functions here.
double computeRate(int days) {
return days * 99.99;
}
double computeRate(int days, string s) {
if(s == "A") {
return days * 169;
} else {
return days * 112;
}
}
Step by step
Solved in 4 steps with 3 images