Question

In: Computer Science

Using Visual Studio write a program that allows the user to enter multiple scores ranging from...

Using Visual Studio write a program that allows the user to enter multiple scores ranging from 0 to 100, computes the average of

those scores and then writes out a letter grade using the typical grading scale. Your program will also:

1. Allow the user to enter any number of scores he or she wishes but assume there will be at least one

score entered.

2. Use a sentinel-controlled loop variable to terminate the loop when the user has no more scores to

enter. Hold user in a loop if a “yes” or “no” is not entered.

3. Use the TryParse method, to hold the user in a loop if a non-numeric value is entered. To exit the loop,

the user must enter correct input.

4. Hold the user in a loop if a value less than 0 or greater than 100 is entered.

Solutions

Expert Solution

using System;

class Program

{

static void Main() {

int n=0,check=1;;

double total=0,score=0,avg;

char grade='a';

string val;

Console.Write("Enter score (no to stop): ");

val = Console.ReadLine();

while (!val.Equals("no"))

{

check=1;

while (check==1)

{

check = 0;

if (!double.TryParse(val,out score))

{

Console.Write("Enter a numeric value!!!: ");

check=1;

val = Console.ReadLine();

}

else if (score<0 || score>100)

{

Console.Write("Score should be greater than 0 and less than 100: ");

val = Console.ReadLine();

check=1;

}

else

{

n=n+1;

total=score+total;

}

}

Console.Write("Enter score (no to stop): ");

val = Console.ReadLine();

}

avg=total/n;

if(avg>=80)

grade='A';

else if(avg>=60)

grade='B';

else if(avg>=50)

grade='C';

else if(avg>=40)

grade='D';

else

grade='F';

Console.WriteLine("Calculated grade: "+grade);

}

}


Related Solutions

USING PYTHON. Thank you in advance Write a program that allows the user to enter a...
USING PYTHON. Thank you in advance Write a program that allows the user to enter a series of string values into a list. When the user enters the string ‘done’, stop prompting for values. Once the user is done entering strings, create a new list containing a palindrome by combining the original list with the content of the original list in a reversed order. Sample interaction: Enter string: My Enter string: name Enter string: is Enter string: Sue Enter string:...
DATA STRUCTURES USING C++ 2ND EDITION Write a program that allows the user to enter the...
DATA STRUCTURES USING C++ 2ND EDITION Write a program that allows the user to enter the last names of five candidates in a local election and the votes received by that candidate. The program should then output each candidates name, votes received by that candidate, and the percentage of the total votes received by the candidate. Your program should also output the winner of the election. A sample output is as follow Johnson    5000 25.91 miller    4000   ...
Write a C++ program using dynamic arrays that allows the user to enter the last names...
Write a C++ program using dynamic arrays that allows the user to enter the last names of the candidates in a local election and the number of votes received by each candidate. The program must ask the user for the number of candidates and then create the appropriate arrays to hold the data. The program should then output each candidate’s name, the number of votes received, and the percentage of the total votes received by the candidate. Your program should...
Use Visual Python or equivalent, to write a program that allows the user to observe the...
Use Visual Python or equivalent, to write a program that allows the user to observe the following: Damped and forced harmonic oscillators. The program should be user friendly and have default values for the initial velocities, positions, masses, and spring constants as well as damping constants. Values and frequencies for the forced oscillators should also be given. It should allow the user to input values for the velocities, positions, spring constants, and masses. The program should determine automatically the scale...
Write a program that runs on SPIM that allows the user to enter the number of...
Write a program that runs on SPIM that allows the user to enter the number of hours, minutes and seconds and then prints out the total time in seconds. Name the source code file “seconds.asm
Write a program that runs on SPIM that allows the user to enter the number of...
Write a program that runs on SPIM that allows the user to enter the number of hours, minutes and seconds and then prints out the total time in seconds. Name the source code file “seconds.asm Explain step by step
Write an application that allows a user to enter any number of student quiz scores, as...
Write an application that allows a user to enter any number of student quiz scores, as integers, until the user enters 99. If the score entered is less than 0 or more than 10, display Score must be between 10 and 0 and do not use the score. After all the scores have been entered, display the number of valid scores entered, the highest score, the lowest score, and the arithmetic average.
Please write the code JAVA Write a program that allows the user to enter the last...
Please write the code JAVA Write a program that allows the user to enter the last names of five candidates in a local election and the number of votes received by each candidate. The program should then output each candidate’s name, the number of votes received, and the percentage of the total votes received by the candidate. Your program should also output the winner of the election. A sample output is: Candidate      Votes Received                                % of Total Votes...
C++ Vector Write a program that allows the user to enter the last names of the...
C++ Vector Write a program that allows the user to enter the last names of the candidates in a local election and the votes received by each candidate. The program should then output each candidate's name, votes received by that candidate, and the percentage of the total votes received by the candidate. Assume a user enters a candidate's name more than once and assume that two or more candidates receive the same number of votes. Your program should output the...
write a c++ program using micro soft visual studio 2010 to write a program and store...
write a c++ program using micro soft visual studio 2010 to write a program and store 36 in variable x and 8 in variable y. add them and store the result in the variable sum. then display the sum on screen with descriptive text. calculate the square root of integer 36 in x. store the result in a variable. calculate the cube root of integer 8 in y. store result in a variable. display the results of square root and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT