1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Kazeer [188]
3 years ago
9

Write a modular program that accepts up to 20 integer test scores in the range of 0 to 100 from the user and stores them in an a

rray. Then main should report how many perfect scores were entered (i.e., scores of 100), using a value-returning countPerfect function to help it. Hint: Have the program count the scores as they are entered. Your program may need this information later.
Computers and Technology
1 answer:
gogolik [260]3 years ago
5 0

Answer:

The program in Java is as follows:

import java.util.*;

public class Main{

public static int countPerfect(int [] scores, int n){

    int count = 0;

    for(int i = 0;i<n;i++){

     if(scores[i] == 100) {count++;}  }

 return count; }

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

 int n;

 System.out.print("Number of scores: ");

 n = input.nextInt();

 if(n<1 || n>20){n=20;}

 int [] scores = new int[n];

 for(int i = 0;i<n;i++){

     scores[i] = input.nextInt();  }

 System.out.print("Perfect Scores: "+countPerfect(scores,n));  

}

}

Explanation:

The countPerfect function begins here

public static int countPerfect(int [] scores, int n){

This initializes the count to 0

    int count = 0;

This iterates through the array elements

    for(int i = 0;i<n;i++){

If current score is 100, count is incremented by 1

     if(scores[i] == 100) {count++;}  }

This returns the value of count

 return count; }

The main begins here

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

This declares the number of scores, n

 int n;

Prompt to enter the number of scores

 System.out.print("Number of scores: ");

This gets input for n

 n = input.nextInt();

If input is less than 1 or greater than 20, n is set to 20

<em>  if(n<1 || n>20){n=20;}</em>

This declares the scores as an array

 int [] scores = new int[n];

This iterates through the array and get inputs for each score

<em>  for(int i = 0;i<n;i++){</em>

<em>      scores[i] = input.nextInt();  }</em>

This calls the function and print the number of perfect scores

 System.out.print("Perfect Scores: "+countPerfect(scores,n));  

}

You might be interested in
Are sql injections legal?
natima [27]

Essentially, if you are seen to be someone who knows what you are doing, then even typing in a single-quote to a web form has been enough to be arrested and charged over in the past.

But lets say i'm writing a pen test tool that will be doing sqli testing and let it loose on sites that are 'out in the wild'. I'm not going to be doing dumps of any information. But is just the vulnerability scan itself illegal?



8 0
4 years ago
Describe what each of the following functions in R do.1. t2. matplot3. c4. seq5. legend6. matrix7. rownames8. colnames9. type of
slega [8]

Answer:

1. t is a function used to transpose a matrix object. The object is passed as an argument to the function.

2. matplot is a graphical function in R used for data visualization.

3. The c function is used to combine arguments.

4. seq is an R function used to derive a range of numbers, optionally specifying a start, stop and step argument or simply a single numeric argument.

5. legends are used in data visualization to list and define items in the graphical presentation.

6. matrix is a function in R used to create and work with matrix and data frame objects.

7. rownames and colnames are functions used to label the row and columns of a data frame in R.

8. The typeof function return the data type of an object.

Explanation:

The R programming language is a dedicated programming language for data analysis and visualization.

5 0
3 years ago
What is a good computer i should get
algol [13]

Answer:

MacBook or a Dell computer in my opinion

Explanation:

5 0
3 years ago
Read 2 more answers
What is the supernatural condition called whereby a human transforms into a wolf?
Paraphin [41]
The supernatural condition whereby a human transforms into a wolf is called a werewolf.
4 0
3 years ago
Read 2 more answers
I Need Help with 6.1.3 circles in squares in codehs
ycow [4]

The program below is able to calculate the area of a circle inscribed in a Square.

<h3>What is a program?</h3>

A program is a set of instructions given to the computer with specific end results in mind.

<u>Sample program in Java

</u>// Java Program to find the area of

// an inscribed circle in a square.

import java.io.*;

class GFG {

   

   static double PI = 3.14;

   

   // Function to find area of an

   // inscribed circle in a square.

   static double areaOfInscribedCircle(float a)

   {

       return ( PI / 4 ) * a * a;

   }

   // Driver code

   public static void main (String[] args)

   {

       float a = 8;

   

       System.out.println("Area of an inscribed"

       + " circle: " + areaOfInscribedCircle(a));

   }

}

Learn more about programs at :
brainly.com/question/1538272
#SPJ1

5 0
2 years ago
Other questions:
  • Alex is nearing graduation. His counselor showed him this information. Alex's College Costs &amp; Payment Options per Year Costs
    5·2 answers
  • AFLAC, Inc. recently implemented a company policy that all new IT projects must be coordinated and approved by the project manag
    8·1 answer
  • Search engines enable you to
    13·2 answers
  • Explain how can we determine that where is the strength of magnetic force maximum in a
    13·1 answer
  • When subjects are given two drinks but not told what they are drinking in order to get accurate results on which is the better t
    6·1 answer
  • To open a Google Doc in another software application, the user must first download it. True or false?
    12·2 answers
  • How to make a project using PID and thermacouple
    11·1 answer
  • There are 2048bytes in4megabytes true or false​
    10·1 answer
  • What are the oop concept of java
    5·2 answers
  • List out any four hardware and software components required for multimedia​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!