FILL IN THE BLANKS #include #include <> *BLANK* using namespace std; int main() { const double HOURLY_RATE = 15; string input_str; cout << "Enter days of attendance: " << endl; *BLANK* (cin, input_str); stringstream input_stream(); int total_hours = 0; while(!input_stream.())*BLANK* { int hours; string day; input_stream >> day; if(day == *BLANK*|| day == *BLANK*) { hours = 5; } *BLANK*(day == "Tuesday" || day == "Thursday") { hours = 4; } else if(day == "Friday") { hours = 3; } else if(day == "Sunday" || day == "Saturday") { hours = 0; cout << "School is not open on the weekends." << endl; } *BLANK* { cout << "Ignoring " << day << endl; } total_hours += hours; } double total_cost = *BLANK* * HOURLY_RATE; if( *BLANK* 300) { total_cost = 300; } else if(total_cost < 75) { total_cost = 75; } cout << "Your weekly rate is $" << total_cost << endl; return 0; }
SOLUTION:
C++ CODE BLANK FILLING:
1.iostream
2.getline
3.while(!input_stream.eof())
4."Monday"
5."Wednesday"
6.else if
7.else
8.total_hours
9.total_cost>300
CODE REWRITTEN BY FILLING BLANKS;
NOTE : Bold words are blanks filled by appropriate words
#include <iostream>
using namespace std;
int main() {
const double HOURLY_RATE = 15; string input_str;
cout << "Enter days of attendance: " << endl;
getline(cin, input_str);
stringstream input_stream();
int total_hours = 0; while(!input_stream.eof()) { int hours; string day; input_stream >> day;
if(day == "Monday"|| day == "Wednesday")
{ hours = 5; }
else if(day == "Tuesday" || day == "Thursday")
{ hours = 4; }
else if(day == "Friday")
{ hours = 3; }
else if(day == "Sunday" || day == "Saturday")
{ hours = 0; cout << "School is not open on the weekends." << endl; }
else { cout << "Ignoring " << day << endl; } total_hours += hours; }
double total_cost =total_hours * HOURLY_RATE;
if( total_cost> 300) { total_cost = 300; }
else if(total_cost < 75) { total_cost = 75; } cout << "Your weekly rate is $" << total_cost << endl; return 0; }
NOTE:
If you are satisfied with my answer please do up vote
and if you have any kind of doubts please post in comment section.
I'll surely help you there.
Thank You:)
FILL IN THE BLANKS #include #include <> *BLANK* using namespace std; int main() { const...
Convert to use functions where possible #include<iostream> #include<string> using namespace std; int main() { string first, last, job; double hours, wages, net, gross, tax, taxrate = .40; double oPay, oHours; int deductions; // input section cout << "Enter First Name: "; cin >> first; cout << "Enter Last Name: "; cin >> last; cin.ignore(); cout << "Enter Job Title: "; getline(cin, job); cout << "Enter Hours Worked:...
#include "stdafx.h" #include <iostream> using namespace std; class dateType { private: int dmonth; int dday; int dyear; public: void setdate (int month, int day, int year); int getday()const; int getmonth()const; int getyear()const; int printdate()const; bool isleapyear(int year); dateType (int month=0, int day=0, int year=0); }; void dateType::setdate(int month, int day, int year) { int numofdays; if (year<=2008) { dyear=year;...
#include <iostream> #include <chrono> using namespace std; double improvedPow(double x, int y) { // To be implemented by you } int main() { cout << "To calculate x^y ..." << endl; double x; int y; cout << "Please enter x: "; cin >> x; cout << "Please enter y: "; cin >> y; if(x == 0) { if (y > 0) cout << 0 << endl; else cout << "x^y is not defined" <<endl; } else { cout << improvedPow(x,y)...
#include <iostream> #include <vector> #include <iomanip> using namespace std; int main() { const int NUM_ITEMS = 8; vector <double> inverse(NUM_ITEMS); int j; double temp; for (int i = 0; i < NUM_ITEMS; i++) { inverse.at(i) = 1 / (i + 1.0); } cout << fixed << setprecision(2); cout << "Original vector..." << endl; for (int i = 0; i < NUM_ITEMS; i++) { cout << inverse.at(i) << " "; } cout << endl; cout << "Reversed vector..." << endl; for...
#include <iostream> #include <string> using namespace std; int main() { int number; int sum = 0; while(true) { cout << "Please enter a number between 1 and 11: "; cin >> number; if (number >= 1 && number <= 11) { cout << number << endl; sum = sum + number; //only add the sum when number is in range: 1-11, so add wthin this if case } else { cout << number << endl; cout << "Out of range;...
Find and fix errors #include <iostream> #include <cstdlib> #include <ctime> using namespace std; const int MIN = 1; const int MAX = 10; int getRandom(int low, int high); int main() { int random_num = 0; int player_num; int tries; int seed = static_cast<int>(time(0)); bool guessed = false; srand(seed); // call the getRandom function below tries = 4; while ( tries > 0 && !guessed ) { cout << "Enter a number within the range 1 to...
Write a C++ Program. You have a following class as a header file (dayType.h) and main(). #ifndef H_dayType #define H_dayType #include <string> using namespace std; class dayType { public: static string weekDays[7]; void print() const; string nextDay() const; string prevDay() const; void addDay(int nDays); void setDay(string d); string getDay() const; dayType(); dayType(string d); private: string weekDay; }; #endif /* // Name: Your Name // ID: Your ID */ #include <iostream>...
In C++ ***//Cat.h//*** #ifndef __Cat_h__ #define __Cat_h__ #include <string> using namespace std; struct Cat { double length; double height; double tailLength; string eyeColour; string furClassification; //long, medium, short, none string furColours[5]; }; void initCat (Cat&, double, double, double, string, string, const string[]); void readCat (Cat&); void printCat (const Cat&); bool isCalico (const Cat&); bool isTaller (const Cat&, const Cat&); #endif ***//Cat.cpp//*** #include "Cat.h" #include <iostream> using namespace std; void initCat (Cat& cat, double l, double h, double tL, string eC,...
Watermelon Problem: The answer should not include any whitespace. #include<iostream> using namespace std; int main() { double distance, gravity =9.8, height; int time, t=0; cout<<"Please input the time of fall in seconds:"<<endl; [ A ] // Get the user input of the time of fall in seconds (Use cin>> method) cout<<endl; cout<<"Please input the height of the bridge in meters:"<<endl; [ B ] // Get the user input of the height of the bridge in meters (Use cin>>...
#include <iostream> #include <sstream> #include <string> using namespace std; int main() { const int index = 5; int head = 0; string s[index]; int flag = 1; int choice; while (flag) { cout << "\n1. Add an Item in the Chores List."; cout << "\n2. How many Chores are in the list."; cout << "\n3. Show the list of Chores."; cout << "\n4. Delete an...