ok, this is what i have to do: Use the program skeleton below starting with #inc
ID: 3608697 • Letter: O
Question
ok, this is what i have to do:Use the program skeleton below starting with #include<stdio.h> as the
starting point. Add the necessary statements to the switchcases.
In case 1 for the switch
(a) print a blank line, a line with the message:"Part I:" and ablank line.
Print a line with the message:
"HOW TO CORRECT UNETHICAL ACTIVITIES:" and a blankline.
(b) Print the following message (11 lines) on the screen:
If you suspect that you or your team is involved in unethical
conducts, what is the best way to remedy the situation:
1. Give an anonymous tip to a newspaper or magazine reporter
2. Receive an advice from your favorite minister orpsychiatrist
3. Consult with your engineering friends
4. Consult with your immediate supervisor
5. Report to your senior managers bypassing your immediatesupervisor
Choose one from 1-5 to be an answer:
When you take an integer from the keyboard, if the answer is 4,
print the message: Yes.
If the answer is incorrect, print the message: No. and printthe
correct answer.
If the character is not in 1-5, print the message:
Sorry, you entered an invalid number.
In case 2 for the switch
(c) print a blank line, a line with the message:"Part II:" and ablank line.
(d) The integer array score[20] holds the test scores of 20students.
Compute the average of the test scores and printthe average using %.2f.
In case 3 for the switch
(e) print a blank line, a line with the message:"Part III:" and ablank line.
(f) Compute the values of the function
f(x)= x*sin(2.*x)-x*x*exp(-x)- 9.0*x + 8.9
from x=0.0 to x=3.5. with an increment ofdel_x=0.25.
Create a table of x and f(x).
Use %8.2f and %14.4e for printing values of xand f(x).
Your output looks like:
-------------------------
x f(x)
-------------------------
0.00 ......
0.25 ......
.... ......
3.25 ......
3.50 ......
*/
this is the basic skeleton:
#include <stdio.h>
#include <math.h>
int main(void)
{
int menu;
int score[20]={77, 97,99, 100, 35, 67, 69, 86, 39, 67,
67, 87, 55, 89, 69, 44, 56, 89, 99, 72};
printf(" There arethree parts. ");
printf("Enter the partnumber to execute (1, 2, or 3): ");
scanf("%d",&menu);
/* form a switch to execute one part */
switch(menu){
case 1:
printf(" Part I: ");
/***** insert your part1 statements ****/
printf(" ");
break;
case 2:
printf(" Part II: ");
/**** insert your part 2statements ****/
printf(" ");
break;
case 3:
printf(" Part III: ");
/**** insert your part 3statements ****/
printf(" ");
break;
default:
printf("part %d does not exist. ", menu);
}
exit(0);
}
thanks.
Explanation / Answer
please rate - thanks the 2 lines in red were added so my DOS window doesn't close stdlib was added for exit #include #include #include #include int main(void) { intmenu,i,submenu,sum; doubleaverage,x,del_x=.25,fx; int score[20]={77, 97,99, 100, 35, 67, 69, 86, 39, 67, 67, 87, 55, 89, 69, 44, 56, 89, 99, 72}; printf(" There arethree parts. "); printf("Enter the partnumber to execute (1, 2, or 3): "); scanf("%d",&menu); /* form a switch to execute one part */ switch(menu){ case 1: printf(" Part I: "); printf("If you suspect that you or your team is involved inunethical "); printf("conducts, what is the best way to remedy thesituation: "); printf("1. Give an anonymous tip to a newspaper or magazinereporter "); printf("2. Receive an advice from your favorite minister orpsychiatrist "); printf("3. Consult with your engineering friends "); printf("4. Consult with your immediate supervisor "); printf("5. Report to your senior managers bypassing your immediatesupervisor "); printf("Choose one from 1-5 to be an answer: "); scanf("%d",&submenu); if(submenu5) printf("Sorry, you entered an invalid number. "); else if(submenu==4) printf("Yes "); else printf("No. The correct answer is 4. Consult with yourimmediatesupervisor "); printf(" "); break; case 2: printf(" Part II: "); sum=0; for(i=0;iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.