Challenge: Combining Structs and Enums
Swipe to start coding
Define a struct named Student that contains an enum Level with the values Freshman, Sophomore, Junior, Senior and a member variable level of type Level.
Write a function named isSenior that takes a Student object as a parameter and returns true if the student's level is Senior, otherwise returns false.
In the main function, create a Student with the level set to Senior and another with the level set to Junior.
Print the result of calling isSenior for both students using the format: "Is the student a senior? {result}", where {result} is true or false.
Oplossing
Bedankt voor je feedback!
single
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.
Awesome!
Completion rate improved to 8.33
Challenge: Combining Structs and Enums
Veeg om het menu te tonen
Swipe to start coding
Define a struct named Student that contains an enum Level with the values Freshman, Sophomore, Junior, Senior and a member variable level of type Level.
Write a function named isSenior that takes a Student object as a parameter and returns true if the student's level is Senior, otherwise returns false.
In the main function, create a Student with the level set to Senior and another with the level set to Junior.
Print the result of calling isSenior for both students using the format: "Is the student a senior? {result}", where {result} is true or false.
Oplossing
Bedankt voor je feedback!
single