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

I am trying to figure out how to properly execute a while loop and a do/while...
I am trying to figure out how to properly execute a while loop and a do/while loop in the same program using java. I am stuck at just writing the while loop. I made a condition but I can't figure out how to get it to loop if the condition is true?? Also I have to write a do/while loop in the same program. here are the details: This lab demonstrates the use of the While Loop and the Do...
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...
Create a console app with C# that uses a while loop to calculate the average of...
Create a console app with C# that uses a while loop to calculate the average of 3 test scores. Input integers, but use the appropriate average data type. Generally, you use a while to do something while a condition is true. You can use a while loop to execute a certain number of times. *While* this is not the best use of the while loop and another loop is generally more appropriate, it follows the pattern below set a counter...
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.
Re-write all with proper code syntax and conventions Add a while loop that continues to ask...
Re-write all with proper code syntax and conventions Add a while loop that continues to ask the age until a blank value is entered, or a user presses cancel. let userage=prompt("enterage"); let userageindays=userage*365; let userageinmonths=userage*12; let useragein hours=userageindays*24 get useragein-minutes=userageinhours*60 let userageinseconds=userageinminutes*60; if userage>=40 { console.log("You are older than 40"; } else { console.log("You are younger than 40"); } switch (true) { case (userage<5): console.log("You are between 0 and 5"); break; case (userage<10): console.log("You are between 5 and 10"); break;...
Implement a version with the outer loop, with a while loop, and the inner loop with...
Implement a version with the outer loop, with a while loop, and the inner loop with a do / while loop. Modify this program as he ask ↑↑↑ C++ // This program averages test scores. It asks the user for the 2 // number of students and the number of test scores per student. 3 #include <iostream> 4 #include <iomanip> 5 using namespace std; 6 7 int main() 8 { 9 int numStudents, // Number of students 10 numTests; //...
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.
The scores on a standardized test have an average of 1200 with a standard deviation of...
The scores on a standardized test have an average of 1200 with a standard deviation of 60. A sample of 50 scores is selected. What is the probability that the sample mean will be between 1195 and 1205? Round your answer to three decimal places.
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....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT