Question

***C++ Only*** Create an enum for the days of the week, starting with Monday. Print your...

***C++ Only***

Create an enum for the days of the week, starting with Monday.

Print your enums, which includes the day of the week and it's numeric value.

Create a 2nd enum for cars. Use Honda, Toyota, Subaru, and Saab.

Print as before.

***C++ Only***

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here I am providing the answer for the above question:

Code:

#include<iostream>
using namespace std;

enum days_of_week { Monday, Tuesday , Wednesday , Thrusday , Friday , Saturday , Sunday}; //enum for the days of the week
enum cars{Honda , Toyota , Subaru , Saab}; // enum for cars

int main()
{
   cout<<"Printing the Week and its values"<<endl;
for(int day=Monday; day<=Sunday; day++) //loop to print week of day and corresponding numeric value.
{
   switch(day)
   {
       case Monday:
           cout<<"Monday:"<<day<<endl;
           break;
       case Tuesday:
           cout<<"Tuesday:"<<day<<endl;
           break;
       case Wednesday:
           cout<<"Wednesday:"<<day<<endl;
           break;
       case Thrusday:
           cout<<"Thrusday:"<<day<<endl;
           break;
       case Friday:
           cout<<"Friday:"<<day<<endl;
           break;
       case Saturday:
           cout<<"Saturday:"<<day<<endl;
           break;
       case Sunday:
           cout<<"Sunday:"<<day<<endl;
           break;
       }
   }
   cout<<"Printing car and its values"<<endl;
   for(int car=Honda; car<=Saab; car++) //loop to print car and its corresponding values.
   {
       switch(car)
       {
           case Honda:
               cout<<"Honda: "<<car<<endl;
               break;
           case Toyota:
               cout<<"Toyota: "<<car<<endl;
               break;
           case Subaru:
               cout<<"Subaru: "<<car<<endl;
               break;
           case Saab:
               cout<<"Saab: "<<car<<endl;
               break;
       }
   }
}

Output:

Hoping that the above code will help you...Thank you....

Add a comment
Know the answer?
Add Answer to:
***C++ Only*** Create an enum for the days of the week, starting with Monday. Print your...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • how to check enums in C let us say I have the following enum: enum days{...

    how to check enums in C let us say I have the following enum: enum days{ MONDAY, SUNDAY, THURSDAY } ; I want to check if a struct that contains this enum has a valid value for example typedef struct { int date; enum day name; } complete_date; so now I want to check if a complete_date has a valid enum it can only be valid if it is MONDAY,SUNDAY, OR THURSDAY. i want to assert that becuase if it...

  • This is my program in C. I should be able to print out Monday, Tuesday and...

    This is my program in C. I should be able to print out Monday, Tuesday and Wednesday. However, I am not sure what I am doing wrong. Please tell me. So far I get these errors: warning: ‘enum day’ declared inside parameter list will not be visible outside of this definition or declaration const char* DayToString(enum color x)// I guess this is just a warning, nothing wrong error: parameter 1 (‘x’) has incomplete type const char* DayToString(enum color x) //I...

  • **C# Visual Basic** You will create a program that uses an enumerator to store the days...

    **C# Visual Basic** You will create a program that uses an enumerator to store the days of the week and months of the year and then ask the user for their birthday and then print it out to the screen along with their age. Your output should look like this: Enter the day of the week you were born on (sun, mon, ect...): Enter the month you were born in (Jan, Feb, ect...): Enter the day of the month you...

  • C/C++ Final Project PROGRAM DUE MONDAY OF FINALS WEEK. Minimum requirements, the program must include the...

    C/C++ Final Project PROGRAM DUE MONDAY OF FINALS WEEK. Minimum requirements, the program must include the following features: Create a program that interacts with the user. Use at least 3 objects (instances of different classes) Use at least one example of inheritance Use at least one pointer Use at least one pass by reference Use at least one overloaded function Use separate files for class definition, class function definition, cpp file that has main Use at least 2 loops Use...

  • C Programming Quesition (Structs in C): Write a C program that prompts the user for a...

    C Programming Quesition (Structs in C): Write a C program that prompts the user for a date (mm/dd/yyyy). The program should then take that date and use the formula on page 190 (see problem 2 in the textbook) to convert the date entered into a very large number representing a particular date. Here is the formula from Problem 2 in the textbook: A formula can be used to calculate the number of days between two dates. This is affected by...

  • python Days of the Week Function Name: days_of_the_week() Parameters: list of birthdays ( list ), year...

    python Days of the Week Function Name: days_of_the_week() Parameters: list of birthdays ( list ), year (int ) Returns: list of names ( list ) Description: You and your friends all want to celebrate your birthdays together, but you don't want to stay up late on a school night. Write a function that takes in a list of tuples formatted as (day ( int ), month ( int ), name (string)), and a year ( int ). Use Python's calendar...

  • Suppose your waiting time for a bus in the morning is uniformly distributed on [0, 8],...

    Suppose your waiting time for a bus in the morning is uniformly distributed on [0, 8], whereas waiting time in the evening is uniformly distributed on [0, 10] independent of morning waiting time. (a) If you take the bus each morning and evening for a week, what is your total expected waiting time? (Assume a week includes only Monday through Friday.) [Hint: Define rv's X1, X10 and use a rule of expected value.] min (b) What is the variance of...

  • Suppose your waiting time for a bus in the morning is uniformly distributed on [0, 8], whereas waiting time in the...

    Suppose your waiting time for a bus in the morning is uniformly distributed on [0, 8], whereas waiting time in the evening is uniformly distributed on [0, 12] Independent of morning waiting time. (a) If you take the bus each morning and evening for a week, what is your total expected waiting time? (Assume a week includes only Monday through Friday.) (Hint: Define rv's X X and use a rule of expected value.] min (b) What is the variance of...

  • Hi, can you please help me with this question. I need it to be in C++....

    Hi, can you please help me with this question. I need it to be in C++. Please without struct and files. Only with functions bc I didnt learn struct and files yet. Many computer applications, such as Microsoft Excel, can compare date values that occur after January 1, 1900. For example, these programs can determine if 06/06/99 is less than (comes before) 11/01/00. They use January 1, 1900 as their reference point. This becomes day 1. All other dates are...

  • 2. + -/6 points DevoreStat9 5.E.064. My Notes + Ask Your Teacher Suppose your waiting time...

    2. + -/6 points DevoreStat9 5.E.064. My Notes + Ask Your Teacher Suppose your waiting time for a bus in the morning is uniformly distributed on [0, 12), whereas waiting time in the evening is uniformly distributed on [0, 16] independent of morning waiting time. (a) If you take the bus each morning and evening for a week, what is your total expected waiting time? (Assume a week includes only Monday through Friday.) (Hint: Define rv's X, ..., X10 and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT