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 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...

  • 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...

  • CT143 : Intro to C++ Lab 15: Array Practice Instructions Complete each of the C++ activities...

    CT143 : Intro to C++ Lab 15: Array Practice Instructions Complete each of the C++ activities described below in a single source file Label each activity with its own heading using comments. Activities: 1) Favorite numbers a. Declare and initialize an array of 10 integers as a single statement using a name of your choice. b. Output the result of adding the 1st and 5th members of the array. C. Subtract the 4h member from 3 times the 10th member...

  • In Java You are to write a program that determines the day of the week for...

    In Java You are to write a program that determines the day of the week for New Year's Day in the year 3000. To do this, you must create your own date class (MyDate) and use the following interface and main program: /** Interface for Date objects to be used by the Year3000 driver program. @author Jon Sorenson */ public interface DateInterface { /** @return the day of the month (1-31) */ public int getDay(); /** @return the day of...

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
ADVERTISEMENT