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...
in C++ use loopDW.cpp below Do While Loop Exercise Get a copy of the loopDW.cpp. Add...
in C++ use loopDW.cpp below Do While Loop Exercise Get a copy of the loopDW.cpp. Add a do-while loop to complete the program. The do-while loop will make sure that a valid mark will be obtained before further process. (hint: a event-controlled do-while loop is needed.) Compile and run the program. Use input values: -10, 30, 59, 70, 75, 96, and 108. Show the output to your lab instructor. #include <iostream> using namespace std; int main() { int mark; char...
Write a program which uses a while loop to add the following numbers: 5, 52, 31,...
Write a program which uses a while loop to add the following numbers: 5, 52, 31, and 65 and output the sum of those numbers. Your output should look like this: The sum of (list the numbers) is ( give the result). //In C language Upload a screen shot of your program and the results of running the program.
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.
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...
JAVA Write nested while loop that will print out this pattern, based upon a number entered...
JAVA Write nested while loop that will print out this pattern, based upon a number entered by the user. User enters 4: 1234 1234 1234 1234 User enters 2: 12 12
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT