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
spin [16.1K]
3 years ago
8

Write a java program which uses methods for calculating the sum of any 5 non-zero integer digits that are input. The program mus

t use scanner for input of the 5 digits. Two Methods must be used, one for calculating the sum of the 5 digits
Computers and Technology
1 answer:
zheka24 [161]3 years ago
3 0

Answer:

public class num1 {

   public static void main(String[] args) {

   //Calling the method Calculate

       calculate();

   }

//Method Calculate

   public static void calculate() {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter five numbers greater than 0");

       int sum =0;

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

           System.out.println("Enter the "+(i+1)+" number");

           sum+=in.nextInt();

       }

       System.out.println("The sum of the five numbers is: "+sum);

   }

}

Explanation:

  • Two Methods are created in Java Programming Language
  • The main method and the method calculate()
  • The calculate method uses a  for loop to request users to enter five numbers
  • Every number entered is added to the sum initially set to 0
  • The sum is printed at the end
  • In the main method, calculate is called.
You might be interested in
A customer reports that recently several files cannot be accessed. The service technician decides to check the hard disk status
Lyrx [107]

Answer:

Back up the user data to removable disk

Explanation:

Before you work on a computer, especially anything that has to do with files not accessible, this might need to format the system because it might either be a virus or other forms of malware. Since backup was done to a different logical partition on the disk, the first thing to do before performing any diagnostic procedures on the disk is to back up the user data to a removable disk in order not to lose the information in the system.

8 0
3 years ago
1. Which of the following statements is true regarding the use of refrigerants?
kondaur [170]
A) Records of the dates and quantities of refrigerant recovered and recycled are unnecessary
5 0
3 years ago
Read 2 more answers
Design pseudocode for a program that will permit a user to store exactly 50 numbers in an array. Create an array big enough to h
galben [10]

Answer:

#include<stdio.h>

//declare a named constant

#define MAX 50

int main()

{

   //declare the array

   int a[MAX],i;

   //for loop to access the elements from user

   for(i=0;i<MAX;i++)

   {

      printf("\n Enter a number to a[%d]",i+1);

      scanf("%d",&a[i]);

  }

  //display the input elements

  printf("\n The array elements are :");

  for(i=0;i<=MAX;i++)

  printf(" %d ",a[i]);

}

Explanation:

PSEUDOCODE INPUTARRAY(A[MAX])

REPEAT FOR I EQUALS TO 1 TO MAX

PRINT “Enter a number to A[I]”

READ A[I]

[END OF LOOP]

REPEAT FOR I EQUALS TO 1 TO MAX

PRINT A[I]

[END OF LOOP]

RETURN

ALGORITHM

ALGORITHM PRINTARRAY(A[MAX])

REPEAT FOR I<=1 TO MAX

PRINT “Enter a number”

INPUT A[I]

[END OF LOOP]

REPEAT FOR I<=1 TO MAX

PRINT A[I]

[END OF LOOP]

6 0
3 years ago
Normally you depend on the JVM to perform garbage collection automatically. However, you can explicitly use ________ to request
Naddik [55]

Answer:

System.gc()

Explanation:

System.gc() can be defined as the method which can be used to effectively request for garbage collection because they runs the garbage collector, which in turn enables JMV which is fully known as JAVA VIRTUAL MACHINE to claim back the already unused memory space of the objects that was discarded for quick reuse of the memory space , although Java virtual machine often perform garbage collection automatically.

7 0
3 years ago
Which of the following items is an example of software? A. WORD PROCESSING PROGRAM B. KEYBOARD C. PRINTER D. MOUSE
Umnica [9.8K]
Well the only one that is actually a piece of programming is A. Word Processing Program. B, C and  D are all peripherals for a computer not actual software for it. Basically if you have to install it on the computer its software. Now B C and D may need software to make them compatible with your computer they themselves dont need to be installed.
8 0
3 years ago
Other questions:
  • Write a Python function called validateCreditCard that takes 8-digit credit card number as the input parameter (string value) an
    8·1 answer
  • Windows uses a memory-management technique known as ________ to monitor which applications you use most frequently and then prel
    8·1 answer
  • True or false.the color attribute cannot recognized the hexadecimal code.
    7·2 answers
  • 1. Accessing calendars, contact information, emails, files and folders, instant messages, presentation, and task lists over the
    7·1 answer
  • The design of a blog refers to:
    10·1 answer
  • Is backing up computer files done on the hard drive?
    14·2 answers
  • When replacing a system board in a laptop, which feature is a must?
    7·1 answer
  • Define power supply and types of power supply<br>​
    11·1 answer
  • In this exercise, you'll raise a manual exception when a condition is not met in a particular function. In particular, we'll be
    10·1 answer
  • A site has been issued the IP address of 192. 168. 10. 0/24. The largest network contained 25 hosts and was given the lowest num
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!