Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For each of the programs assigned below, submit the following: Copy of the sourc

ID: 3596049 • Letter: F

Question

For each of the programs assigned below, submit the following: Copy of the source code (.c) saved as an electronic attachment Assignment 5 located in Canvas under Assignments. Word docx file with screen captures of sample executions for all cases presented in problems. . 1. Write a program · . to prompt the user to enter the length of a shape and the height of that same shape Next, prompt the user to enter the type of shape they would like to calculate the area of: a rectangle(have them enter a character R) or a triangle(have them enter a character T) Using an if structure, call a function called AreaRect if the user entered R. AreaRect should accept two inputs(length and height) and should return the area to main. .Else Call a function called AreaTri, AreaTri should accept two inputs(length and height) and should return the area to main. Using a second if structure, print "the area of the rectangle is %lf" if the user entered R Else print "the area of the triangle is %lf" . Run with sample data: h-43, 1-64, shape-T and h=3.7,7.2, shape-R 2. Write a program to calculate a student's grade based on three test scores, using the guidelines below: Write a function readScores and call it three times to read three test scores (between 0 and 100) using data type float for the scores. Call a function calculateGrade to determine the student's grade from the three test scores using the algorithm below. The function calculateGrade receives the three scores and returns the grade as a character. Implement the algorithm using nested statements within a given range rather than merely simple if statements. The grade is not printed from this function . * hese are the guidelines: If the average score is 90% or more, the grade is A. If the average score is 70% or more and less than 90%, check the third score. If the third score is more than 90%, the grade is A, otherwise the grade is B If the average score is 50% or more and less than 70%, check the average of the second and third scores. If the average of the two is greater than 70%, the grade is C; otherwise the grade is D If the average score is less than 50% then the grade is F o Print the student's grade from function main (or if you prefer, from a printResults function) . Test with the following sets of scores: a.Test 1 score: 74 Test 1 score: 62 t1 score: 52 1 score: 54 Test 2 score: 82 Test 2 score: 84 Test 2 score: 64 Test 2 score: 62 Test 3 score: 92 Test 3 score: 73 Test 3 score: 85 Test 3 score: 61

Explanation / Answer

Question 1.

#include<stdio.h>
float AreaRect(float length,float height);
float AreaTri(float length,float height);

int main()
{
char tsh;
float length,height;
puts("enter length and height of shape");
scanf("%f%f",&length,&height);
puts("enter the type of shape(R-Rectangle,T-Triangle)");
scanf(" %c", &tsh);
if(tsh=='T')
{
printf("Area of the triangle is=%3.2f",AreaTri(length,height));
}
if(tsh=='R')
{
printf("Area of the Rectangle is=%3.2f",AreaRect(length,height));
}
}


float AreaRect(float length,float height)
{
return length*height;
}

float AreaTri(float length,float height)
{
return .5*length*height;
}

output:

D:C Program>gcc Chegg1.c -o Chegg1

D:C Program>Chegg1.exe

enter length and height of shape

3.7

7.2

enter the type of shape(R-Rectangle,T-Triangle)

R

Area of the Rectangle is=26.64

Question 2.


#include<stdio.h>
float readscores();
calculateGrade(float test1,float test2, float test3);

int main()
{
float test1,test2,test3;

test1=readscores();
test2=readscores();
test3=readscores();
char result=calculateGrade(test1,test2,test3);
printf("");

}


float readscores()
{
float testscore;
scanf("%f",&testcore);
return testscore;;
}

char calculateGrade(float test1,float test2, float test3)
{
char status;
float avg=(test1+test2+test3)/3;
if(avg>90)
{
status='A';
}
else if(avg>=70 & avg<90)
{
if(test3>90)
{
status='A';
}
else
{
status='B';
}
}

else if(avg>=50 & avg<70)
{
if((test2+test3)/2>70)
{
status='C';
}
else
{
status='D';
}
}

else if(avg<50)
{
status='F';
}

}

Output:

D:C Program>gcc CheggGrade.c -o CheggGrade

D:C Program>CheggGrade.exe

74

82

92

Your Grade is=A

D:C Program>CheggGrade.exe

62

84

73

Your Grade is=B

D:C Program>CheggGrade.exe

52

64

85

Your Grade is=C