Question

In: Computer Science

construct c program flow chart #include <stdio.h> #include <math.h> #include <string.h> #define num 6 #define b...

construct c program flow chart

#include <stdio.h>
#include <math.h>
#include <string.h>

#define num 6
#define b 6
#define t 6

double bmical(double w, double h){
double o;
double bmi;

o = pow(h,2);
bmi = w/o;
return bmi;
}

double maxheartrate(int num1, int age){
double mhr;

mhr = num1 - age;
return mhr;
}

double heartratereserve(double mhr, double rhr){

double hrr;
hrr = mhr - rhr;

return hrr;
}

double minrange(int hrr, int rhr){

double mirt;
mirt = (hrr * 0.7) + rhr;

return mirt;
}

double maxrange(int hrr, int rhr){

double mart;
mart = (hrr * 0.85) + rhr;

return mart;
}

int main() {

printf("Online Application for Sports Teacher's Position 2019\n\n");

char N[90];
int A;
double P;
char E[20];
char grade;
double score;
char G;
double S;
int count;
double g;
double total;
double cgpa;
double h;
double w;
double bmi;
double hbpm;
int n = 220;
int mark[10];
int sum;
int average;
int i;
int marks[10];
int ave;
int s;
int tot;

printf("Name: ");
scanf("%s%s%s", &N,&N,&N);

printf("Phone number: ");
scanf("%lf", &P);

printf("Email address: ");
scanf("%s", &E);

printf("Age: ");
scanf("%d", &A);

if(A>=21&&A<=26){
printf("You are qualified!\n\n");
}
else if(A<21){
printf("You are not qualified!\n\n");
return 0;
}
else if (A>26) {
printf("You are not qualified!\n\n");
return 0;
}

printf("---------------------------------------------- \n\n");

printf("Enter your Sport Science Grade [A,B,C,D,F]: ");
scanf("%s", &grade);

if(grade == 'A')
score = 4.0;
else if(grade == 'B')
score = 3.0;
else if(grade == 'C')
score = 2.0;
else if(grade == 'D')
score = 1.0;
else if(grade == 'F')
score = 0.0;

else {
score = -1;
printf("Invalid grade '%c'\n", grade);
}
if(score != -1)
printf("Your score is %.2f\n", score);

if(score>=2&&score<=4){
printf("You are qualified!\n\n");
}
else if(score<1){
printf("You are not qualified!\n\n");
return 0;
}


printf("Enter your English grade [A,B,C,D,F]: ");
scanf("%s", &G);

switch(G){
case'A':
S = 4.0;
break;
case 'B':
S = 3.0;
break;
case 'C':
S = 2.0;
break;
case 'D':
S = 1.0;
break;
case 'F':
S = 0.0;
break;
default:
S = -1;
printf("Invalid grade '%c'\n", G);
break;

}
if(S !=-1)
printf("Your score is %.2f\n", S);

if(S>=2&&S<=4){
printf("You are qualified!\n\n");
}
else if(S<1){
printf("You are not qualified!\n\n");
return 0;
}

count = 0;
total = 0;

while(count < num){
printf("Enter you GPA each sem: ");
scanf("%lf", &g);
total += g;
count++;
}

cgpa = total/num;
printf("Your CGPA is: %.2f\n", cgpa);

if(cgpa>=2.5&&cgpa<=4){
printf("You are qualified!\n\n");
}
else if(cgpa<2.5){
printf("You are not qualified!\n\n");
return 0;
}

for(i=0; i< b; ++i)
{
printf("Enter your 'Fitness Test' mark for each sem: ");
scanf("%d", &mark[i]);

sum += mark[i];

}

average = sum/b;
printf("Average marks = %d\n\n", average);


if(average < 12){
printf("You are not qualified!\n\n");
return 0;
}
else if(average>=12&&average<=20){
printf("You are qualified!\n\n");
}
else if (average>=21) {
printf("Invalid, please enter correctly!\n\n");
return 0;
}

for(s=0; s< t; ++s)
{
printf("Enter your 'Bleep Test' mark for each sem: ");
scanf("%d", &marks[s]);

tot += marks[s];

}

ave = tot/t;
printf("Average marks = %d\n\n", ave);

if(ave<5.0){
printf("You are not qualified!\n\n");
return 0;
}
else{
printf("You are qualified!\n\n");
}

printf("----------------------------\n\n");

printf("Enter your weight (kg): ");
scanf("%lf", &w);
printf("Enter your height (m): ");
scanf("%lf", &h);

bmi = bmical(w,h);
printf("Your BMI is %.2f\n\n", bmi);

if(bmi < 18.5){
printf("You are underweight!\n");
}
else if(bmi>=18.5&&bmi<=24.9){
printf("You are healthy!\n");
}
else if(bmi>=25&&bmi<=29.9){
printf("You are overweight!\n");
}
else{
printf("You are obese!\n");
}

if(bmi < 18.5){
printf("You are not qualified!\n\n");
return 0;
}
else if(bmi>=18.5&&bmi<=24.9){
printf("You are qualified!\n\n");
}
else if (bmi>=25) {
printf("You are not qualified!\n\n");
return 0;
}

printf("-----------------------------------------------------------\n\n");
printf("Enter your heart beats per min when you are at rest: ");
scanf("%lf", &hbpm);

if(hbpm < 40){
printf("You are not qualified!\n\n");
return 0;
}
else if(hbpm>=40&&hbpm<=100){
printf("You are qualified!\n\n");
}
else if (hbpm > 100) {
printf("You are not qualified!\n\n");
return 0;
}

int res = maxheartrate(n, A);
printf("Maximum heart rate = %d\n\n", res);

printf("'Resting heart rate = Heart beats per min when you are at rest' \n");

int res1 = heartratereserve(res, hbpm);
printf("Heart Rate reserve (HRR) = %d\n\n" , res1);

double res2 = minrange(res1, hbpm);
printf("Mininum range target heart zone is %.2f\n" , res2);

double res3 = maxrange(res1, hbpm);
printf("Maximum range target heart zone is %.2f\n\n" ,
res3);

printf("Average target heart rate zone for exercise intensity; \n");
printf("Moderate exercise intensity: %.2f\n", res2);
printf("Vigorous exercise intensity: %.2f\n", res3);

printf("------------------------------------------------------------------------\n\n");

printf("Congratulations! You are shortlisted for Sports Teacher's Position 2019.\n");
printf("Results will be announced next week via email, Thank You!\n\n");

return 0;
}

Solutions

Expert Solution


Related Solutions

C program. librarys that are in use; stdio.h, stdlib.h, time.h, stddef.h, ctype.h, math.h, string.h. Need to...
C program. librarys that are in use; stdio.h, stdlib.h, time.h, stddef.h, ctype.h, math.h, string.h. Need to rewrite the functions linked in the code: "return add_move_lib ( board, col, colour ) ;" "return board_full_lib ( board ) ;" "return display_board_lib ( board ) ; // TASKS // board_full() display_board() add_move() // adds a token of the given value (1 or 2) to the board at the // given column (col between 1 and COLS inclusive) // Returns 0 if successful, -1...
Can you translate this C code into MIPS assembly? #include <stdio.h> #include <math.h> #include <stdlib.h> double...
Can you translate this C code into MIPS assembly? #include <stdio.h> #include <math.h> #include <stdlib.h> double fact (double); void main () { int angle_in_D; double term, angle_in_R; float sine = 0; unsigned int i = 1; double sign = 1; int n = 1000; printf ("Please enter an angle (Unit: Degree): "); scanf ("%d", &angle_in_D); angle_in_R = angle_in_D * M_PI / 180.0; do { term = pow(-1,(i-1)) * pow (angle_in_R, (2*i - 1)) / fact (2*i - 1); sine =...
#include <stdio.h> #include <stdlib.h> #include <math.h> #include "../include/cis1057.h" /* * Programmer: << MA >> * Class:...
#include <stdio.h> #include <stdlib.h> #include <math.h> #include "../include/cis1057.h" /* * Programmer: << MA >> * Class: Introduction to C Programming 1057 Spring 2019 Section 004 * Assignment: Number 5 “estimate the value of a factorial using Gosper's algorithm." * Date: << 02-19-2019 >> * Version: 1 * Description: Program will prompt for some data, read in the values, perform the calculation using library math functions, and display the result. * File: lab5.c */ # define M_PI 3.14159265358979323846 /* pi */...
CODE A #include<stdio.h> #include<math.h> #include<stdlib.h> #define PI 3.14159265358979323846 int main(){ int diameter; printf("Enter value of diameter...
CODE A #include<stdio.h> #include<math.h> #include<stdlib.h> #define PI 3.14159265358979323846 int main(){ int diameter; printf("Enter value of diameter between 8 to 60 inches: "); scanf("%d",&diameter); // if(diameter>60 || diameter<=8){ // printf("Error! invalid input"); // exit(0); // } // else{ // float radius = diameter/2; // float volume = (4/3)*PI*radius*radius*radius; // printf("%.2f",volume); // } //check through the while loop if it is valid or in valid while(diameter>60 || diameter<=8){ printf("Invalid input Enter again: "); scanf("%d",&diameter); }    //caluclate the volume of sphere float...
Please implement the 5 questions in source code: #include <stdio.h> #include <stdlib.h> #include <math.h> int main(...
Please implement the 5 questions in source code: #include <stdio.h> #include <stdlib.h> #include <math.h> int main( int argc, char* argv[] ) { // Size of vectors int n = 10000; // Input vectors double *restrict a; double *restrict b; // Output vector double *restrict c; // Size, in bytes, of each vector size_t bytes = n*sizeof(double); /* Q1: Allocate memory for vector a (10 points)*/ /* Q2: Allocate memory for vector b (10 points)*/ /* Q3: Allocate memory for vector...
*****MUST ONLY USE****** #include <iostream> #include <fstream> #include <string.h> #include <stdio.h> Description The word bank system...
*****MUST ONLY USE****** #include <iostream> #include <fstream> #include <string.h> #include <stdio.h> Description The word bank system maintains all words in a text file named words.txt. Each line in the text file stores a word while all words are kept in an ascending order. You may assume that the word length is less than 20. The system should support the following three functions: Word lookup: to check whether a given word exists in the word bank. Word insertion: to insert a...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> int main(int argc, char *argv[]) {     FILE *myFile;...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> int main(int argc, char *argv[]) {     FILE *myFile;     char fname[20];     //int sum = 0;     int i, j, k, tmp =0;     int num = 0;     int mass = 0;     int count = 0;     int fuel = 0;     int total = 0;     int M[1000];     char ch;     char buffer[32];     printf(" Input the filename to be opened : ");     scanf("%s",fname);     myFile = fopen(fname, "r");     if(myFile == NULL)     {         printf("Can't open file\n");     } while(1)     {         ch =...
please fix code #include <stdio.h> #include <stdlib.h> #include <string.h> // function declarations int getValidJerseyNumber(); int getValidRating();...
please fix code #include <stdio.h> #include <stdlib.h> #include <string.h> // function declarations int getValidJerseyNumber(); int getValidRating(); int main() { // declaring variables int size = 5; int jerseyNo[size]; int rating[size]; int i = 0, jno, rate; char option; /* Getting the inputs entered by the user * and populate the values into arrays */ for (i = 0; i < size; i++) { printf("Enter player %d's jersey number:", i + 1); jerseyNo[i] = getValidJerseyNumber(); printf("Enter player %d's rating:\n", i +...
My current code that is not working correctly #include<stdio.h> #include<math.h> int main() { //variable declaration int...
My current code that is not working correctly #include<stdio.h> #include<math.h> int main() { //variable declaration int a,b,c,D,n; double x1,x2; double realPart, imagPart; do { // this set of code blocks prompts a message to the user and then read the integer entered and stores it as an integer printf("Enter a value for a:\n"); scanf("%d",&a); printf("Enter a value for b:\n"); scanf("%d",&b); printf("Enter a value for c:\n"); scanf("%d",&c); printf("You entered the Equation \n"); printf("%dx^2%+dx%+d=0\n",a,b,c); D = b*b - 4*a*c;    if (D<0)...
#include <stdio.h> #include <math.h> int fun(int); int main(void)    {     int i = 5, x...
#include <stdio.h> #include <math.h> int fun(int); int main(void)    {     int i = 5, x = 3;     i = fun(x);     printf("%d\n", i);     return 0; } int fun(int i) {      int res = 0;      res = pow (i , 3.0);      return ( res); }
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT