Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello! I am in CSCI 111 and I have a problem I can\'t compute. If you purchase a

ID: 3676340 • Letter: H

Question

Hello! I am in CSCI 111 and I have a problem I can't compute.

If you purchase anything online, you are usually given an estimated arrival date such as 5 to 10 business days. You will write a program to prompt for the current day and number of “shipping” days (elapsed days). Then, determine the day of the week your item is expected to “arrive.” We will simplify the program and allow for an item to ship and arrive on any day of the week, including weekend.

Input: day of week, String-three-symbol day; also elapsed days, int

Output: current day of week; future day of week

Sample Output: Enter a day of the week: ex. sun - sunday, mon - monday... etc.

thu: Enter number of shipping days

16: 16 days away from thursday is saturday

Enter a day of the week:

flat: error! Day cannot be determined

This is all that was given and I am very confused... Please help if possible! Thanks so much!

Explanation / Answer

#include<iostream>
#include<string>

using namespace std;

enum Day{sun,mon,tue,wed,thu,fri,sat};

int getDayNumber(string day){
   if(day.compare("sun") == 0)
       return 0;
   else if(day.compare("mon") == 0)
       return 1;
   else if(day.compare("tue") == 0)
       return 2;
   else if(day.compare("wed") == 0)
       return 3;
   else if(day.compare("thu") == 0)
       return 4;
   else if(day.compare("fri") == 0)
       return 5;
   else if(day.compare("sat") == 0)
       return 6;
   else
       return -1;
   }
  
string getDay(int dayNumber){
   string day;
   switch(dayNumber){
       case 0:
           day = "sunday";
           break;
       case 1:
           day = "monday";
           break;
       case 2:
           day = "tuesday";
           break;
       case 3:
           day = "wednesday";
           break;
       case 4:
           day = "thursday";
           break;
       case 5:
           day = "friday";
           break;
       case 6:
           day = "saturday";
      
       }
   return day;
   }
int main(){
   string day;
   int shippingDays;
  
   cout<<"Enter a day of the week: ";
   cin>>day;
  
   cout<<"Enter number of shipping days: ";
   cin>>shippingDays;
  
   string shippingDayName;
   string currentDayName;
   int remainder = shippingDays%7;
  
   int curentDayNumber = getDayNumber(day);
   currentDayName = getDay(curentDayNumber);
   if(curentDayNumber == -1)
       cout<<"error! Day cannot be determined ";
   else{
           shippingDayName = getDay((curentDayNumber+remainder)%7);
           cout<<shippingDays<<" days away from "<<currentDayName<<" is "<<shippingDayName<<endl;
       }
  
   return 0;
   }


/*

Output:

Enter a day of the week: thu
Enter number of shipping days: 16
16 days away from thursday is saturday

*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote