a. Write a program that will compute the average of any number
of test scores
using a do-while loop.
b. Revise the code to employ a while loop.
c. Revise the code to employ a for loop.
Since you have not mentioned the language of your preference, I am providing the code in C++.
a)
CODE
#include <iostream>
using namespace std;
int main() {
double scores[] = {56, 67, 99, 91, 87, 88};
int n = 6;
double average = 0;
int i = 0;
do {
average += scores[i];
i ++;
} while(i < n);
cout << "Average = " << average/n;
}
b)
CODE
#include <iostream>
using namespace std;
int main() {
double scores[] = {56, 67, 99, 91, 87, 88};
int n = 6;
double average = 0;
int i = 0;
while(i < n) {
average += scores[i];
i ++;
}
cout << "Average = " << average/n;
}
c)
CODE
#include <iostream>
using namespace std;
int main() {
double scores[] = {56, 67, 99, 91, 87, 88};
int n = 6;
double average = 0;
for (int i=0; i<n; i++) {
average += scores[i];
}
cout << "Average = " << average/n;
}
a. Write a program that will compute the average of any number of test scores using...
Write a program that uses a while loop to read in a series of test scores, then calculates the average. Control the number of repetitions by using a sentinel value. In python ty
Write a program that allows the user to enter a series of exam scores. The number of scores the user can enter is not fixed; they can enter any number of scores they want. The exam scores can be either integers or floats. Then, once the user has entered all the scores they want, your program will calculate and print the average of those scores. After printing the average, the program should terminate. You need to use a while loop...
Write a program to ask for the scores of a set of students (one at a time ) and to compute and display the class average as follows: How many students? 5 What is the score for students #1? 78 What is the score for students #2? 90 What is the score for students #3?88 What is the score for students #4? 68 What is the score for students #5? 98 The class average is average ?? <= compute and...
Using the nested loop in C++ to finish the program
//test scores. //It asks the user for the // number of students and //the number of test scores //per student. // Calc. and display average score // for each TEST 2 4 6 7
In C, write a program to read 5 student scores from keyboard the average of test score. Use for loop. Instead of entering the 5 scores each time you run the program, you can use i/o redirect. Create an input file inputfor.txt, then add 5 scores in it. Run the command like this: scorefor < inputfor.txt
Write a program using Java language to enter any random 10 double numbers. This program should compute the average and display it. To write this program you have to use while loop.
Write a C++ program that asks user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’ names and ranking. Follow the Steps Below Save the project as A4_StudentRanking_yourname....
C++
4. Write a program that inputs 5 scores using a do while loop and asks a user whether to continue or not ("yes" or "no il pressed you continues if pressed no' terutiinales) then calculates the average. 5. Make a program calculates sales for its division and quarterly earnings and show the total sum. Use 5 by 2 array matrix 6. This is an extra credil questioni Produce a program that displays by decreasing or decremeniting by 4 starting...
import java.util.*; /** Description: This program determines the average of a list of (nonnegative) exam scores. Repeats for more exams until the user says to stop. Input: Numbers, sum, answer Output: Displays program description Displays instruction for user Displays average Algorithm: 1. START 2. Declare variables sum, numberOf Students, nextNumber, answer 3. Display welcome message and program description 4. DOWHILE user wants to continue 5. Display instructions on how to use the program 6. Inititalize sum and number of student...
Write a javascript program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Write the following methods in the program: calcAverage—This method should accept five test scores as arguments and return the average of the scores. determineGrade—This method should accept a test score as an argument and return a letter grade for the score,