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
NARA [144]
4 years ago
3

Array testGrades contains NUM_VALS test scores. Write a for loop that sets sumExtra to the total extra credit received. Full cre

dit is 100, so anything over 100 is extra credit. Ex: If testGrades
Computers and Technology
2 answers:
Sidana [21]4 years ago
6 0

Answer:

/**

a for loop that sets sumExtra to the total extra credit received.

**/

import java.util.Scanner;

public class SumOf Excess {

public static void main (String [

args) {

final int NUM_VALS

int [] testGrades = 4;

new int [NUM_VALS];

int i;

int sumExtra = -9999;

/** Assign

sumExtra with 0 before your

for loop**/

testGrades [0] = 101;

testGrades [ 1] = 83;

testGrades [2] = 107;

testGrades [3] = 90;

sumExtra = 0;

for(i = 0 ;i < testGrades.length

:++i){

if(testGrades [i]> 100){

testGrades [i] = sumExtra - 100+ SumExtra;

}

else {

System.out.println("sumExtra:

sumExtra);

}

}

Explanation:

total extra credit received. Full credit

is 100, SO anything over 100 is

extra credit.

Ex If testGrades = {101, 83, 107, 90

then sum Extra = 8, because 1 +0+ 7

+0 is 8.

Kruka [31]4 years ago
3 0

Complete Question:

Array testGrades contains NUM_VALS test scores. Write a for loop that sets sumExtra to the total extra credit received. Full credit is 100, so anything over 100 is extra credit Ex: If testGrades = {101, 83, 107, 90}, then sumExtra = 8, because 1 + 0 + 7 + 0 is 8."

Answer:

import java.util.Arrays;

import java.util.Scanner;

public class SumOfExcess {

   public static void main (String [] args) {

       Scanner in = new Scanner(System.in);

       final int NUM_VALS = 5;

       int[] testGrades = new int[NUM_VALS];

       int sumExtra = 0;

       System.out.println("Enter the test scores for the five courses");

       testGrades[0]= in.nextInt();

       for(int i =1; i<testGrades.length; i++){

           System.out.println("Enter next score");

           testGrades[i]= in.nextInt();

       }

       System.out.println("The test scores are "+ Arrays.toString(testGrades));

//Finding the sum of excess credit

       for(int i = 0 ;i < testGrades.length; ++i){

           if(testGrades[i] > 100){

               sumExtra = testGrades[i] - 100 + sumExtra;

           }

           else {

           }

       }

       System.out.println("Total sumExtra: " + sumExtra);

   }

}

Explanation:

  • This has been solved using Java programming language
  • create the array of type int and of length NUM_VALS in this case 5 int[] testGrades = new int[NUM_VALS];
  • Use a for loop to request user to enter the values for the credits
  • Use Java's Arrays.toString Method to display the array after all the values have been entered
  • Create and initialize the variable sumExtra
  • Using a second for loop iterate the entire array, using an if statement determine values above 100, subtract the extra value and add to the variable sumExtra

You might be interested in
What do the points on this website do?
DanielleElmas [232]

Answer:

They allow you to ask more questions and also your rank goes up or down.

Explanation:

5 0
3 years ago
Read 2 more answers
Pros and cons of using the internet
MAVERICK [17]
It is easy to find information, but it is not always right.
7 0
3 years ago
Read 2 more answers
PLEASE HELP MEH IDK WHAT TO DO!!!!! PLEASE!!!!!!!!!!!!
Over [174]
I would ask myself c
3 0
4 years ago
Read 2 more answers
What are the advantages and disadvantages of using steganography versus symmetric or asymmetric encryption
ankoles [38]

<u>Explanation:</u>

Steganography is a technique used in securing or hiding sensitive information by encrypting the information in a non-hidden file like a JPEG format. A major <u>advantage</u> of this method is that it reduces the risk of attack or break-in since the data is enclosed in a non-secure file; thereby reducing threats of any hack. One main<u> disadvantage</u> of this method is that the hidden message may become difficult to recover if the source file (non-secure file) used, is edited or deleted.

In symmetric or asymmetric encryption they both employ cryptographic encryption method. While symmetric encryption uses one key to encrypt and decrypt data, asymmetric encryption uses two keys (one for encryption, the other for decryption) of the data. <u>A major </u><u>advantage</u><u> of using these methods is that they provide more security. Although while symmetric encryption is faster, asymmetric encryption is slower (eg using separate keys to gain access), </u><u>a disadvantage.</u>

6 0
3 years ago
Which of the following best describes a situation where software should be upgraded instead of replaced? A three-year-old laptop
Karo-lina-s [1.5K]
The six month old computer that needs more RAM is the answer. it is the only one using software.
6 0
4 years ago
Other questions:
  • Do opportunity costs only occur when making spending decisions
    5·1 answer
  • What technology changes led to industrialization?
    15·1 answer
  • Which of the actions below will not create more room on your hard drive?
    13·1 answer
  • In a certain computation, 90% of the work is vectorizable. Of the remaining 10%, half is parallelizable for an MIMD machine. Wha
    9·1 answer
  • Suppose h(m) is a collision-resistant hash function that maps a message of arbitrary bit length into an n-bit hash value. is it
    5·1 answer
  • Publishers that participate in a display ad network _____ a) get paid each time an advertiser is charged by the ad network for d
    7·1 answer
  • A simulation model includes: a. a description of the components of the system. b. a simulation clock. c. a definition of the sta
    8·1 answer
  • A hardware compatibility list recommends striping with double parity as storage for an application. In a test environment, a tec
    13·1 answer
  • anyone here done intro to tech course on edgenuity yet? I failed the first unit test twice and it's prob gonna be a third if i r
    14·2 answers
  • Contagem progressiva e regressiva usando estrutura condicional enquanto no visualg
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!