Question

In: Computer Science

Open Average Test Scores while loop, comment out the while loop and add a for loop...

Open Average Test Scores while loop, comment out the while loop and add a for loop that averages 4 test scores. Code C#

While loop code

using System;
class Program
{
static void Main() {
int count = 0, total = 0, number;
  
while (count < 3)
{
Console.Write("Enter a number: ");
number = Convert.ToInt32(Console.ReadLine());
total += number;
count++;
}
  
double average = total / 3.0;
Console.Write("Average = " + average.ToString("####0.00"));
}
}

Solutions

Expert Solution

using System;
class Program
{
static void Main() {
int count = 0, total = 0, number;
  
for(count = 0; count <4; count++) // loops 4 times
{
Console.Write("Enter a number: ");
number = Convert.ToInt32(Console.ReadLine());
total += number;
}
  
double average = total / 4.0;
Console.Write("Average = " + average.ToString("####0.00"));
}
}
// Hit the thumbs up if you are fine with the answer. Happy Learning!


Related Solutions

Hello, I Have create this code and Tried to add do while loop but it gives...
Hello, I Have create this code and Tried to add do while loop but it gives me the error in string answar; and the areas where I blod So cloud you please help me to do ( do while ) in this code. // Program objective: requires user to input the data, program runs through the data,calcualtes the quantity, chacks prices for each iteam intered,calautes the prices seperatly for each item, and calculates the amount due without tax, and then...
Modify the previous program to use the Do-While Loop instead of the While Loop. This version...
Modify the previous program to use the Do-While Loop instead of the While Loop. This version of the program will ask the user if they wish to enter another name and accept a Y or N answer. Remove the "exit" requirement from before. Output: Enter the full name of a person that can serve as a reference: [user types: Bob Smith] Bob Smith is reference #1 Would you like to enter another name (Y or N)? [user types: y] Enter...
Open SAT data. Test if there is a significant difference in SAT and Letter scores. Answer...
Open SAT data. Test if there is a significant difference in SAT and Letter scores. Answer the questions for Assessment. (Pick the closest answer) 4. What is the P-value? a. 4.98093E-69 b. 0.256823064 c. 6.18089E-06 d. None of these 5. What is the Statistical interpretation? a. The P-value is much smaller than 5% thus we are very certain that average Letter scores are different from average SAT scores. b. The P-value is too large to have a conclusive answer. c....
A drug that is supposed to increase test scores had an average of 83 with a...
A drug that is supposed to increase test scores had an average of 83 with a standard deviation of 14 , with 35 test subjects . The control group of 22 subjects who were given the placebo scored an average of 86 with a deviation of 12. Test the claim that the drug is effective in improving test scores. With a significance level of 0.05.
Study the following code with a while-loop and convert it to a for-loop (fill in the...
Study the following code with a while-loop and convert it to a for-loop (fill in the blanks). int i=4, result=1; while(i>1) { result *= i; i--; } The following for-loop performs the same functionality: int result=1; for (__________ i=4; i _________1;____________) { result *= i; }
What is the difference between a for loop and a while loop? When is it ideal...
What is the difference between a for loop and a while loop? When is it ideal to use a for loop, and when is it ideal to use a while loop? Can they be used interchangeably? Does it depend on the circumstance? Furthermore, what is your professional opinion on the advisability of the absence of the do while loop in the MATLAB programming language? If you use outside resources or ideas that are not your own to help make your...
C language and it has to be a while loop or a for loop. Use simple...
C language and it has to be a while loop or a for loop. Use simple short comments to walk through your code. Use indentations to make your code visibly clear and easy to follow. Make the output display of your program visually appealing. There is 10 points deduction for not following proper submission structure. An integer n is divisible by 9 if the sum of its digits is divisible by 9. Develop a program that: Would read an input...
Do men score higher on average compared to women on their statistics test? test scores of...
Do men score higher on average compared to women on their statistics test? test scores of ten randomly selected male statistics students and twelve randomly selected female statistics students are shown below. Male: 63 91 92 56 76 61 83 61 62 71 Female: 46 85 57 53 46 70 46 72 53 61 84 46 Assume both follow a Normal distribution. What can be concluded at the the α = 0.05 level of significance level of significance? For this...
Do men score lower on average compared to women on their statistics test? Test scores of...
Do men score lower on average compared to women on their statistics test? Test scores of thirteen randomly selected male statistics students and twelve randomly selected female statistics students are shown below. Male:  84 80 91 86 78 80 69 93 64 81 75 95 63 Female:  92 76 99 73 80 99 70 95 97 95 94 74 Assume both follow a Normal distribution. What can be concluded at the the αα = 0.05 level of significance level of significance? For...
Standard scores & Correlation Name X(observed scores of test: all 3 trials) Average scores Percentile rank...
Standard scores & Correlation Name X(observed scores of test: all 3 trials) Average scores Percentile rank Z scores T scores Calculate the standard deviation, mean, the percentile rank, Z score, T score of 2 groups (A&B) from the test and display all the scores on the tables (you need 2 different tables). Complete the table with the 15 students. Chapter 10 Balance Group A: 1st attempt 2nd attempt 3rd attempt Student1 2.93 sec 5.89 sec 4.13 sec Student2 1.72 sec...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT