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

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   ...
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...
write a program in c++ that asks the user to enter their 5 test scores and...
write a program in c++ that asks the user to enter their 5 test scores and calculates the most appropriate mean. Have the results print to a text file and expected results to print to screen.
In Python, write a program that allows the user to enter a number between 1-5 and...
In Python, write a program that allows the user to enter a number between 1-5 and returns the vitamins benefits based on what the user entered. The program should: Continue to run until the user quits and Validate the user’s input (the only acceptable input is 0, 1, 2, 3, 4, or 5), If the user enters zero “0” the program should terminate You can use the following facts: 1- Vitamin A protects eyes from night blindness and age-related decline...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT