Question
C++ Practice with Branching In this lab you are going to determine the name of the day (Monday, Tuesday, etc.) and whether or not the
C++
Practice with Branching
In this lab you are going to determine the name of the day (Monday, Tuesday, etc.) and whether or not the day is a Week day or Weekend, based on the inputted numeric day. There is a bit of starter code already in place below, so you will add to. You can probably complete the lab exercise by simply reading the starter code and the comments inside it, but I will outline here as well.
You will see a few user inputs. The third user input is the variable day:
int day; cin >> day;
The variable day stores a number between 1 and 365. If day=1, that is equivalent to Jan 1. If day=2, that is equivalent to Jan. 2 and so on. Next, you will see the second user input is the variable dayOne:
int dayOne; cin >> dayOne;
This variable keeps track of the what day of the week day =1 (Jan. 1) is. For example, if dayOne = 0 means that Jan. 1 is a Monday (or day = 1 is a Monday). Another example, if dayOne = 2 means that Jan. 1 is a Wednesday (or day = 1 is a Wednesday).
Lastly, you will see the first user input is the variable option:
int option; cin >> option;
If option = 1, it will test the first branch of code which outputs the name of the day (Monday, Tuesday, etc.) and if option = 2, it will test the second branch of code which outputs either Weekend or Week day.
//TO DO: Header comments here
#include
int main() {
//option=1 means testing output Monday, Tuesday, etc. //option=2 means testing output of Week day or Weekend int option; cin >> option;
//dayOne = 0 means Day 1 is Monday //dayOne = 1 means Day 1 is Tuesday //...etc. int dayOne; cin >> dayOne; //day stores the day number in a year //A number between 1 and 365 //day = 1 is Jan 1, day = 2 is Jan 2, etc. int day; cin >> day; if (option == 1) {
//TO DO: write code in this branch that outputs //day of week (e.g. Monday, Tuesday, etc.) } else if (option == 2) { //TO DO: write code in this branch that outputs //Week day or Weekend }
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started