Question

In: Computer Science

OBJECTIVE-C For this program a teacher needs to be able to calculate an average of test...

OBJECTIVE-C

For this program a teacher needs to be able to calculate an average of test scores for students in their course. Your program must ask the Professor ho many students and how many tests will be averaged per student. Your program should then allow the Professor to enter scores for each student one at a time and then average those scores together. For example, if a student has 5 scores to be entered and the scores are 80, 60, 65,98, and 78 the average should be 76.2%

Here is what I got.

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{

int students, numOfScores, scores, sum;
float average;
NSLog(@"Enter number of students");
scanf("%i", &students);
NSLog(@"Enterh number of scores");
scanf("%i", &numOfScores);
int n;
int s;
for (n = 1; n <= students; n++){
for (s = 1; s <= numOfScores; s++)
{

NSLog(@"Enter the score");
scanf("%i", &scores);
sum = sum + scores;   
}
  
}
average = (float) sum / numOfScores;
NSLog(@"An average score is %f", &average);

return 0;
}

Solutions

Expert Solution

Please find your solution below and if any doubt or need change comment and do upvote.

CODE:

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{
   int students, numOfScores, scores, sum;
   float average;
   //take user input
   NSLog(@"Enter number of students");
   scanf("%d", &students);
   NSLog(@"Enterh number of scores");
   scanf("%d", &numOfScores);
   int n;
   int s;
   
   //using loop sum the enter values
   for (n = 1; n <= students; n++)
   {
       sum=0;//reset to 0 for each next student
       for (s = 1; s <= numOfScores; s++)
       {
         
         //add thte scores
          NSLog(@"Enter the score");
          scanf("%d", &scores);
          sum = sum + scores;   
       }
       //find the average and print it
       average=(float)sum/numOfScores;
       NSLog(@"An average score is %.1f", average);
   }


return 0;
}

OUTPUT:


Related Solutions

MUST BE DONE IN C (NOT C++) In this program we will calculate the average of...
MUST BE DONE IN C (NOT C++) In this program we will calculate the average of x students’ grades (grades will be stored in an array). To do so, please follow these guidelines: - Your program should ask the user for the number of students that are in the class. This number should help you declare your array. - Use the function seen in class to scan the grades of the array. In other words, we will populate the array...
IN C++ Write a program that uses nested loops to collect data and calculate the average...
IN C++ Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask the user for the number of years. The outer loop will iterate once for each year. The inner loop will iterate 12 times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all iterations, the ­­program should display the...
......C++ PROGRAM.... Teacher would like us to split this program into a header file(filename.h), and a...
......C++ PROGRAM.... Teacher would like us to split this program into a header file(filename.h), and a .cpp file(filename.cpp). He gave us all the code, we just need to split it up. I do not quite understand how to do it. Please send output screenshot to show validation. #include <iostream> using namespace std; //public class class Account{ public: //instance variables double amount;    //creates account and sets amount with users account set-up value Account(double a){ amount = a; }    //adds...
A local instructor wants you to write a c++ program using arrays to calculate the average...
A local instructor wants you to write a c++ program using arrays to calculate the average score made on exams by her students. For simplicity, she always has only 12 students in each course she teaches. She teaches multiple subjects so she would like to enter the name of the exam. She wants the program to also determine the highest and lowest scores and the number of students who passed and failed the exam. A score of 60 or above...
Write a C++ program that uses nested loops to collect data and calculate the average rainfall...
Write a C++ program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask the user for the number of years. The outer loop will iterate once for each year. The inner loop will iterate 12 times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all iterations, the program should display the number...
Instructions: Write a program to calculate students’ average test scores and their grades. You may assume...
Instructions: Write a program to calculate students’ average test scores and their grades. You may assume the following input data: Johnson 85 83 77 91 76 Aniston 80 90 95 93 48 Cooper 78 81 11 90 73 Gupta 92 83 30 69 87 Blair 23 45 96 38 59 Clark 60 85 45 39 67 Kennedy 77 31 52 74 83 Bronson 93 94 89 77 97 Sunny 79 85 28 93 82 Smith 85 72 49 75 63...
Write a program in C A teacher will assign homework and give the number of days...
Write a program in C A teacher will assign homework and give the number of days for the students to work on. The student is responsible for calculating the due date. The teacher does not collect homework on Friday or weekend. Write a C program that let the user enter today’s day of the week (0 for Sunday, 1 for Monday, etc.) and the number of days to allow the students to do the work, which may be several weeks....
Write a program in Objective C that takes an integer keyed in from the terminal and...
Write a program in Objective C that takes an integer keyed in from the terminal and extracts and displays each digit of the integer in Eglish. So if the user types 647, the program should display the following: six four seven
C++, Complete this program as directed // This program will read in a group of test...
C++, Complete this program as directed // This program will read in a group of test scores (positive integers from 1 to 100) // from the keyboard and then calculate and output the average score // as well as the highest and lowest score. There will be a maximum of 100 scores. // PLACE YOUR NAME HERE #include <iostream> using namespace std; typedef int GradeType[100]; // declares a new data type: // an integer array of 100 elements float findAverage...
C++ Write a program that asks a teacher to input a student’s first name, last name,...
C++ Write a program that asks a teacher to input a student’s first name, last name, and four test scores. The program should find the average of the four test scores and should then write the following information to a file named “students.txt” last_name first_name average A student's first name of “XX” should be used as a sentinel value and no numeric grades less than 0 or greater than 100 should be accepted.  The program should then read the information in...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT