Question

In: Computer Science

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.

Solutions

Expert Solution

python:

Code:

#count to store the number of valid inputs
count=0
#highdcore
highscore=-1
#low score
lowscore=100
#variable to store sum
s=0
#an infinite loop which only breaks when 99 is entered
while(True):
   #taking input
   num=int(input("Enter Quiz score "))
   #checking if it is 99
   if(num == 99):
       break
   #if it is not between 0 and 10
   if(num<0 or num>10):
       print("Score must be between 10 and 0")
       #starting again from the loop
       continue
   #incrementing count
   count=count+1
   #adding num to sum
   s=s+num
   #getting highscore
   if(highscore<num):
       highscore=num
   #getting lowscore
   if(lowscore>num):
       lowscore=num
#finding average
avg=s/count
#printing results
print("Average is "+str(avg))
print("Highest score is "+str(highscore))
print("Lowest score is "+str(lowscore))
print("Count is "+str(count))

Output:

Code Screenshot:

Code Snippet:

#count to store the number of valid inputs
count=0
#highdcore
highscore=-1
#low score
lowscore=100
#variable to store sum
s=0
#an infinite loop which only breaks when 99 is entered
while(True):
        #taking input
        num=int(input("Enter Quiz score "))
        #checking if it is 99
        if(num == 99):
                break
        #if it is not between 0 and 10
        if(num<0 or num>10):
                print("Score must be between 10 and 0")
                #starting again from the loop
                continue
        #incrementing count
        count=count+1
        #adding num to sum
        s=s+num
        #getting highscore
        if(highscore<num):
                highscore=num
        #getting lowscore
        if(lowscore>num):
                lowscore=num
#finding average
avg=s/count
#printing results
print("Average is "+str(avg))
print("Highest score is "+str(highscore))
print("Lowest score is "+str(lowscore))
print("Count is "+str(count))

java:

code:

//importing this package as we are using Scanner class
import java.util.*;
//class name is Quiz score so, file should be saved as QuizScore.java
class QuizScore{
   //main method
   public static void main(String[] args) {
       Scanner s = new Scanner(System.in);
       //declaring variables
       int count=0;
       int high=-1;
       int low=100;
       int sum=0;
       float avg;
       int num;
       //an infinite loop which onl breaks when 99 is entered
       while(true){
           //taking input
           System.out.println("Enter Quiz Score");
           num=s.nextInt();
           //checking if it is 99
           if(num==99){
               //if 99 is entered break
               break;
           }
           //checking if the number is not between 10 and 0 or not
           if(num<0 || num>10){
               //if it is not then starting loop again
               System.out.println("Score must be between 10 and 0");
               continue;
           }
           //incrementing count
           count++;
           //adding num to sum
           sum=sum+num;
           //finding highest and lowest
           if(high<num){
               high=num;
           }
           if(low>num){
               low=num;
           }


       }
       //finding average and printing results
       avg=sum/count;
       System.out.println("Average is "+avg);
       System.out.println("Highest score is "+high);
       System.out.println("Lowest score is "+low);
       System.out.println("Count is "+count);
   }
}

Output:

Code Screenshot:

Code Snippet:

//importing this package as we are using Scanner class
import java.util.*;
//class name is Quiz score so, file should be saved as QuizScore.java
class QuizScore{
        //main method
        public static void main(String[] args) {
                Scanner s = new Scanner(System.in);
                //declaring variables
                int count=0;
                int high=-1;
                int low=100;
                int sum=0;
                float avg;
                int num;
                //an infinite loop which onl breaks when 99 is entered
                while(true){
                        //taking input
                        System.out.println("Enter Quiz Score");
                        num=s.nextInt();
                        //checking if it is 99
                        if(num==99){
                                //if 99 is entered break
                                break;
                        }
                        //checking if the number is not between 10 and 0 or not
                        if(num<0 || num>10){
                                //if it is not then starting loop again
                                System.out.println("Score must be between 10 and 0");
                                continue;
                        }
                        //incrementing count
                        count++;
                        //adding num to sum
                        sum=sum+num;
                        //finding highest and lowest
                        if(high<num){
                                high=num;
                        }
                        if(low>num){
                                low=num;
                        }


                }
                //finding average and printing results
                avg=sum/count;
                System.out.println("Average is "+avg);
                System.out.println("Highest score is "+high);
                System.out.println("Lowest score is "+low);
                System.out.println("Count is "+count);
        }
}

C:

Code:

#include<stdio.h>
//main function
int main(){
   //declaring and initializing variables
   int count=0;
   int high=-1;
   int low=100;
   int sum=0;
   int num;
   //an infinite loop which only breaks when 99 is entered
   while(1){
       //takng user input
       printf("Enter Quiz score: ");
       scanf(" %d",&num);
       //if num is 99 loop terminates
       if(num==99){
           break;
       }
       //if num is not between 0 and 10 loop starts again
       if(num<0 || num>10){
           printf("Score must be between 10 and 0\n");
           continue;
       }
       //increment count
       count++;
       //adding num to sum
       sum=sum+num;
       //finding highest and lowest
       if(high<num){
           high=num;
       }
       if(low>num){
           low=num;
       }
      
   }
   //finding average
   float avg=sum/count;
   //printing results
   printf("Average is %.2f\n",avg);
   printf("Highest score is %d\n",high);
   printf("Lowest Score is %d\n",low);
   printf("The count is %d",count);
}

Output:

Code Screenshot:

Code Snippet:

#include<stdio.h>
//main function
int main(){
        //declaring and initializing variables
        int count=0;
        int high=-1;
        int low=100;
        int sum=0;
        int num;
        //an infinite loop which only breaks when 99 is entered
        while(1){
                //takng user input
                printf("Enter Quiz score: ");
                scanf(" %d",&num);
                //if num is 99 loop terminates
                if(num==99){
                        break;
                }
                //if num is not between 0 and 10 loop starts again
                if(num<0 || num>10){
                        printf("Score must be between 10 and 0\n");
                        continue;
                }
                //increment count
                count++;
                //adding num to sum
                sum=sum+num;
                //finding highest and lowest
                if(high<num){
                        high=num;
                }
                if(low>num){
                        low=num;
                }
                
        }
        //finding average
        float avg=sum/count;
        //printing results
        printf("Average is %.2f\n",avg);
        printf("Highest score is %d\n",high);
        printf("Lowest Score is %d\n",low);
        printf("The count is %d",count);
}

Related Solutions

Write an application that allows a user to enter the names and birthdates of up to...
Write an application that allows a user to enter the names and birthdates of up to 10 friends. Continue to prompt the user for names and birthdates until the user enters the sentinel value ZZZ for a name or has entered 10 names, whichever comes first. When the user is finished entering names, produce a count of how many names were entered, and then display the names. In a loop, continuously ask the user to type one of the names...
Show: Create an application that allows the user to enter the number of calories and fat...
Show: Create an application that allows the user to enter the number of calories and fat grams in a food. The application should display the percentage of the calories that come from fat. If the calories from fat are less than 30% of the total calories of the food, it should also display a message indicating the food is low in fat. One gram of fat has 9 calories, so: Calories from fat = fat grams *9 The percentage of...
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
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...
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...
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...
Write a MATLAB program to do the following: 1- Allows the user to enter unlimited number...
Write a MATLAB program to do the following: 1- Allows the user to enter unlimited number of data set. 2- Allows the user to exit the program at any time by entering zero. 3- Calculates and displays the following statistics for the entered data set: a- Count of positive, negative, and total numbers. b- Maximum and Minimum numbers. c- Sum and Average of positive numbers. d- Sum and Average of negative numbers. e- Overall Sum and overall average of all...
Android Studio. Java. Please create an application that -> An activity that allows user to enter...
Android Studio. Java. Please create an application that -> An activity that allows user to enter name, gender, date of birth, state of residence (selected from a pre-defined list: CA, AZ, NV, OR), email address and favorite website. This activity has a button "Show Data" that displays detail entered
Student scores on a chapter quiz are:
Student scores on a chapter quiz are:                 6 3 4 9 7 5 5 2 10 9 8 4 4 7 6 3 2 10 9 5 a) Find the mean, median, mode and midrange for this data. b) Find the range, standard deviation and variance for this data. c) Find the z-score for the value 7 and the cutoffs for the data set that are considered unusual.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT