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
Pavlova-9 [17]
2 years ago
12

Your classmate is frustrated because the code that was designed to add up her five quiz grades is not working properly.

Computers and Technology
1 answer:
inna [77]2 years ago
7 0

Answer:

sum = 0 must be before for loop. If inside for loop, it will keep resetting sum to 0 each iteration.

Explanation:

hope this helps

You might be interested in
SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Assume that the classes listed in the Java Quick R
Ne4ueva [31]

Answer:

Check the explanation

Explanation:

CODE:-

import java.util.*;

class UserName{

  ArrayList<String> possibleNames;

  UserName(String firstName, String lastName){

      if(this.isValidName(firstName) && this.isValidName(lastName)){

          possibleNames = new ArrayList<String>();

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

              possibleNames.add(lastName+firstName.substring(0,i));

          }  

      }else{

          System.out.println("firstName and lastName must contain letters only.");

      }

  }

  public boolean isUsed(String name, String[] arr){

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

          if(name.equals(arr[i]))

              return true;

      }

      return false;

  }

  public void setAvailableUserNames(String[] usedNames){

      String[] names = new String[this.possibleNames.size()];

      names = this.possibleNames.toArray(names);

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

          if(isUsed(usedNames[i],names)){

              int index = this.possibleNames.indexOf(usedNames[i]);

              this.possibleNames.remove(index);

              names = new String[this.possibleNames.size()];

              names = this.possibleNames.toArray(names);

          }

      }

  }

  public boolean isValidName(String str){

      if(str.length()==0) return false;

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

          if(str.charAt(i)<'a'||str.charAt(i)>'z' && (str.charAt(i)<'A' || str.charAt(i)>'Z'))

              return false;

      }

      return true;

  }

  public static void main(String[] args) {

      UserName person1 = new UserName("john","smith");

      System.out.println(person1.possibleNames);

      String[] used = {"harta","hartm","harty"};

      UserName person2 = new UserName("mary","hart");

      System.out.println("possibleNames before removing: "+person2.possibleNames);

      person2.setAvailableUserNames(used);

      System.out.println("possibleNames after removing: "+person2.possibleNames);

  }

}

Kindly check the attached image below for the code output.

5 0
3 years ago
Create a Racket procedure compute_pos that reads numbers from the keyboard until 0 is read, count how many positive numbers are
Artyom0805 [142]

Answer:

import java.util.Scanner;

public class Solution {

   public static void main(String args[]) {

       compute_pos();

     }

     

     public static void compute_pos(){

     Scanner scan = new Scanner(System.in);

     int sum = 0;

     int counter = 0;

     // Prompt the user to enter an input

     System.out.println("Enter your value");

     // user input is assign to the variable value

     int value = scan.nextInt();

     

     while(value != 0){

         if (value > 0){

             sum += value;

             counter++;

         }

         System.out.println("Enter your value");

         value = scan.nextInt();

     }

     // Display the value of sum to the user

     System.out.println("The sum of the positive number is: " + sum);

     // Display the value of counter to the user

     System.out.println("The number of positive number is: " + counter);

   }

}

Explanation:

The first line import the Scanner class which allow the program to read input from the user. The class Solution is then defined. Then the main method which signify the beginning of execution in the program is defined. A method is called inside the main method.

The method compute_pos is defined. Inside the compute_pos method, a scanner object scan is declared to accept input from the user via the keyboard.

The variable sum and counter is declared and assigned to 0.

A prompt is displayed to the user to input a value. The user input is accepted and stored in the variable value.

Then a while loop is use to check the user input if it is not equal to zero. If it is equal to zero, the loop will end. Inside the loop, we first check to see if the user input is greater than 0, if it is, we add it to the variable sum and increase our counter by 1. At the end of the loop, a prompt is again display to accept input from the user.

Outside the loop, we display the sum and counter to the user.

8 0
3 years ago
If I have an Animal superclass with a Mammal subclass, both concrete and both having a method called eat() with identical signat
Katarina [22]

Answer:

(c) the dynamic type of reference will determine which of the methods to call.

Explanation:

Polymorphism in Object Oriented Programming typically means the same method name can cause different actions depending on which object it is invoked on. Polymorphism allows for dynamic binding in that method invocation is not bound to the method definition until the program executes.

So in the case of Animal superclass and Mammal subclass, both having a method called eat() with identical signatures and return types, depending on which reference, the correct method eat() will be called dynamically upon execution.

For example, if we have the following;

================================

<em>Mammal mammal = new Animal();</em>

<em>mammal.eat()</em>

================================

The eat() method that will be called is the one in the Mammal subclass.

However, if we have;

================================

<em>Animal animal = new Animal();</em>

<em>animal.eat()</em>

================================

The eat() method of the Animal superclass will be called.

5 0
3 years ago
Which tool would be the best choice for removing and replacing the motherboard bios chip?
mamaluj [8]

An <u>IC extractor</u> would be the best choice for removing and replacing the motherboard bios chip.

<h3>What is a computer hardware?</h3>

A computer hardware can be defined as a physical component of an information technology (IT) or computer system that can be seen and touched.

<h3>The hardware components of a computer.</h3>

Some examples of the hardware components of a computer system and these include:

  • Random access memory (RAM).
  • Read only memory (ROM).
  • Central processing unit (CPU)
  • Keyboard
  • Monitor
  • Mouse
  • Motherboard bios chip

In Computer technology, an <u>IC extractor</u> would be the best choice for removing and replacing the motherboard bios chip.

Read more on motherboard bios chip here: brainly.com/question/17373331

#SPJ1

8 0
1 year ago
The conceptual phase of any system or just the software facet of a system best describes the sdlc
geniusboy [140]
I think its the systems investigation phase.
5 0
3 years ago
Other questions:
  • A hub transmits all incoming messages to all of its ports except the port where the messages came in. A switch usually sends mes
    14·2 answers
  • Use the image above to determine which toolbars will be displayed in the program you are using. SELECT ALL THAT APPLY
    11·2 answers
  • Briefly summarize two examples of cybercrime stories.<br> quick pleaseeee
    10·1 answer
  • Wireless data networks are particularly susceptible to known ciphertext attacks.
    10·1 answer
  • Write a program to enter a number and test if it is greater than 45.6. If the number entered is greater than 45.6, the program n
    10·1 answer
  • Karin realized that a song takes up a lot more space on her computer than the lyrics of the song typed out in ms word document .
    12·1 answer
  • I’m gonna ask this again because I REALLY need an answer.
    10·2 answers
  • What is a spreadsheet​
    12·1 answer
  • A debate about city schools are more better than village schools​
    8·1 answer
  • 236. A system such as a printer, smart TV, or HVAC controller, typically uses an operating system on what is called a:
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!