ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 02 May 2017 My Price 8.00

#include<iostream>

I can't seem to figure put what I'm doing wrong I need to use a switch statement but I can't seem to figure out what I am doing wrong. How do I use a switch statement in my current program I'm trying to figure out.  here is my program so far how do I change the if to a switch statement. How do I change the if statements to a switch statement.

 

 

#include&lt;iostream&gt;
#include&lt;string&gt;
using namespace std;
string getDay(int);
int main() {
for (int i = 0; i &lt; 9; i++) {
cout &lt;&lt; getDay(i) &lt;&lt; endl;
}
}
string getDay(int x) {
if (x == 1) {
return &quot;Monday&quot;;
}
else if (x == 2) {
return &quot;Tuesday&quot;;
}
else if (x == 3) {
return &quot;Wednesday&quot;;
}
else if (x == 4) {
return &quot;Thursday&quot;;
}
else if (x == 5) {
return &quot;friday&quot;;
}
else if (x == 6) {
return &quot;Saturday&quot;;
}
else if (x == 7) {
return &quot;Sunday&quot;;
}
else {
return &quot;ERROR&quot;;
}
}

Answers

(11)
Status NEW Posted 02 May 2017 02:05 AM My Price 8.00

-----------

Not Rated(0)