Question

In: Computer Science

Write a program to take input of scores for Chemistry, Biology and English for a student...

Write a program to take input of scores for Chemistry, Biology and English for a student and display the average with 2 decimal places if all of the three scores are in the range between 1 and 100 inclusive. Program should also display the course name for which scores are entered out of range telling Average couldn't be calculated.

Following is a sample run:

Enter scores for Chemistry, Biology and English between 1 and 100:
45
89
96
Avg score is 76.67

Following is another sample run:

Enter scores for Chemistry, Biology and English between 1 and 100:
900
78
89
Average cannot be calculated because Chemistry Scores were not in range.

Following is another sample run:

Enter scores for Chemistry, Biology and English between 1 and 100:
89
767
8787
Average cannot be calculated because Biology Scores were not in range.
Average cannot be calculated because English Scores were not in range.

Following is another sample run:

Enter scores for Chemistry, Biology and English between 1 and 100:
87
90
-1
Average cannot be calculated because English Scores were not in range.

Solutions

Expert Solution

Required program in C -->

#include<stdio.h>
int main(){
int chemistry, biology, english; //declare variables chemistry,biology, and english as integer
float average; //declare variables average as float
printf("Enter chemistry marks");
scanf("%d",&chemistry); //read chemistry marks
printf("Enter biology marks");
scanf("%d",&biology); //read biology marks
printf("Enter english marks");
scanf("%d",&english); //read english marks
if(chemistry>=0&& chemistry<=100 &&biology>=0 && biology<=100 && english>=0 && english<=100){
average=(chemistry+biology+english)/3; //if in range, then calculate average
printf("%.2f",average); // print average with 2 decimal points
}
else{
if(chemistry<0 || chemistry>100){ //if chemistry not in range, print chemistry not in range
printf("Average cannot be calculated because chemistry Scores were not in range.");
}
if(biology<0 || biology>100){ //if biology not in range, print biology not in range
printf("Average cannot be calculated because Biology Scores were not in range.");
}
if(english<0 || english>100){   //if english not in range, print english not in range
printf("Average cannot be calculated because English Scores were not in range.");
}
}
  
}


Related Solutions

Using C++. Write a program to input marks of five subjects Physics, Chemistry, Biology, Mathematics and...
Using C++. Write a program to input marks of five subjects Physics, Chemistry, Biology, Mathematics and Computer. The input marks must be inserted one subject at a time. The program then calculate percentage and grade according to given conditions: If percentage >= 90% : Grade A If percentage >= 80% : Grade B If percentage >= 70% : Grade C If percentage >= 60% : Grade D If percentage >= 40% : Grade E If percentage < 40% : Grade...
A college offers teaching in Math, English, Chemistry, and Biology. The number of students enrolled in...
A college offers teaching in Math, English, Chemistry, and Biology. The number of students enrolled in each subject is listed below. If the college can only afford to hire 19 teachers, determine how many teachers should be assigned to each subject using Jefferson's method. (a) Subject Students Enrolled Teacher to Assign Math 370 English 265 Chemistry 105 Biology 80 (b) What modified divisor did you use?
Write a program that calculates the average of upto 100 English distances input by the user....
Write a program that calculates the average of upto 100 English distances input by the user. Create an array of objects of the Distance class, as in the ENGLARAY example in this chapter. To calculate the average, you can borrow the add_dist() member function from the ENGLCON example in Chapter 6. You’ll also need a member function that divides a Distance value by an integer. Here’s one possibility: void Distance::div_dist(Distance d2, int divisor) { float fltfeet = d2.feet + d2.inches/12.0;...
Write a program that translates an English word into a Pig Latin word. Input ONE, and...
Write a program that translates an English word into a Pig Latin word. Input ONE, and ONLY one, word from the user, and then output its translation to Pig Latin. The rules for converting a word to Pig Latin follow. The general form for converting a word is to remove the first letter. Then append to the end of the word a hyphen, followed by the first letter that was removed, followed by "ay". For example, "robot" becomes "obot-ray" and...
Write a program in Java that will take as input two sets A and B, and...
Write a program in Java that will take as input two sets A and B, and returns a list of all functions from A to B.
write a program that will display student grade if scores is greater than or equal to...
write a program that will display student grade if scores is greater than or equal to 70 to display A or else if score is less than or equal to 70 and greater than or equal to 60 display B if scores is less than 60 or greater than 50 display C else display fail.
5. Write a CH program that takes the marks of a student as input and prints...
5. Write a CH program that takes the marks of a student as input and prints the grade on screen according to the following criteria: CRITERIA LESS THAN 60 GREATER THAN 60 BUT LESS THAN 65 GREATER THAN 65 BUT LESS THAN 70 GREATER THAN 70 BUT LESS THAN 75 GREATER THAN 75 BUT LESS THAN 80 GREATER THAN 80 BUT LESS THAN 85 GREATER THAN 85 BUT LESS THAN 90 GREATER THAN 90 GRADE F D D+ с C+...
Write a java program that will take a line of input and go through and print...
Write a java program that will take a line of input and go through and print out that line again with all the word numbers swapped with their corresponding numeric representations (only deal with numbers from one to nine). Sample runs might look like this: Please enter a line of input to process: My four Grandparents had five grandchildren My 4 grandparents had 5 grandchildren without array and methods.
THIS IS FOR DEVC++. I use the 5.11 version Write a program to take input of...
THIS IS FOR DEVC++. I use the 5.11 version Write a program to take input of scores for Chemistry, Biology and English for a student and display the average with 2 decimal places if all of the three scores are in the range between 1 and 100 inclusive. Program should also display the course name for which scores are entered out of range telling Average couldn't be calculated. Following is a sample run: Enter scores for Chemistry, Biology and English...
Write a program that will take a line of input and go through and print out...
Write a program that will take a line of input and go through and print out that line again with all the uppercase letters swapped with the lowercase letters. JAVA Using printf
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT