Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question: I need a step by step walkthrough of the code if possible(basically comments) #define _CRT_SECURE_NO_WARNINGS #include #define MAX_JUDGES 3 #define MAX_STRING 25 #define MAX_CONTESTANTS

Question:

I need a step by step walkthrough of the code if possible(basically comments)

#define _CRT_SECURE_NO_WARNINGS

#include

#define MAX_JUDGES 3

#define MAX_STRING 25

#define MAX_CONTESTANTS 10

#define WINNER_CUTOFF 6.5

struct Score { double judgeScore[MAX_JUDGES]; };

struct Contestant { char name[MAX_STRING]; struct Score score; double average; };

struct Competition { char compName[MAX_STRING]; struct Contestant contestants[MAX_CONTESTANTS];

int numContestants; };

double avg(const struct Contestant* c) { return (c->score.judgeScore[0] + c->score.judgeScore[1] + c->score.judgeScore[2]) / 3.0; }

int main(void) {

struct Contestant winners[MAX_CONTESTANTS] = { { 0 } };

struct Competition national = { "National", { { "Jill Smith", { { 4.4 , 8 , 7 } }}, { "Ellen Jones", { { 7.5 , 5.5 , 8 } }}, { "Joan Bell", { { 6.5 , 5.5 , 7 } }}, }, 3 };

int i, j, k, numWinners = 0;

for (i = 0; i

if (national.contestants[i].average >= WINNER_CUTOFF) {

for (j = 0; j

// no code to see here }

for (k = numWinners; k > j; k--) {

winners[k] = winners[k - 1]; } winners[j] = national.contestants[i]; numWinners++; } }

printf("Winners of the %s competition ", national.compName);

for (i = 0; i

image text in transcribedimage text in transcribed
this question is about polymorphism. Select all true statements: Select one or more: O method overriding is not the same as dynamic binding dynamic binding is used when executing a polymorphic method Polymorphism needs the substitution principle and method overriding Polymorphism is the substitution principle and dynamic binding O Polymorphism uses the three following ingredients: 1 Substitution principle, e.g.: Character ch =new Warrior(); 2 Method overriding, e.g.: public void attack(){...} 3 polymorphic method, e.g.: ch.attack() dynamic binding only happens for polymorphism Polymorphism needs the substitution principle and dynamic binding but not method overridingThe 3 pillars of DDFI are encapsulation, inheritance, Er. polymorphism. You have already experienced creating your own classes by encapsulating data ITIEITIIJEFEBI. functions into one unit (class). Inheritance En polymorphism are 2 important features of DDF'. Discuss their importance by using your own research. Discuss how inheritance and polymorphism would be used in your own example. Discuss the design of the objects and if any relationship exists between them, for example, inheritance

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Android 4 Application Development

Authors: Reto Meier

3rd Edition

1118223853, 9781118223857

More Books

Students also viewed these Programming questions

Question

How many functional groups are in the molecule below? Answer

Answered: 1 week ago