**Please help fix code, code is not running and not giving output* Question to be answered: Using the code in the image provided: Implement a method called summation which adds two integers and returns their sum. INPUT: The first line of input contains an integer a. The Second Line of input containes and integer b. OUTPUT: Print the result which is the sum of a and b.   CODE: import java.util.*; import java.io.*; import java.math.*; class Outcome {     /*      * Implement method/function with name 'summation' below.      * The function accepts following as parameters.      *  1. a is of type int.      *  2. b is of type int.      * return int.      */     public static void main(String[] args)   {   Scanner sc=new Scanner(System.in);   int a,b;   a=sc.nextInt(); // enter 1st integer   b=sc.nextInt(); // enter 2nd integer   int sum=summation(a,b);   // call function   System.out.println(sum);  // display message   }     public static int summation(int a,int b){         //Write your code here        int s=0;      s=a+b;         // compute sum       return s;        //return type "int".     } }

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter8: Advanced Method Concepts
Section: Chapter Questions
Problem 8RQ
icon
Related questions
Question
100%

**Please help fix code, code is not running and not giving output*

Question to be answered: Using the code in the image provided:

Implement a method called summation which adds two integers and returns their sum.

INPUT:

The first line of input contains an integer a.

The Second Line of input containes and integer b.

OUTPUT:

Print the result which is the sum of a and b.

 

CODE:

import java.util.*;
import java.io.*;
import java.math.*;
class Outcome {

    /*
     * Implement method/function with name 'summation' below.
     * The function accepts following as parameters.
     *  1. a is of type int.
     *  2. b is of type int.
     * return int.
     */
    public static void main(String[] args) 
 {
  Scanner sc=new Scanner(System.in);
  int a,b;
  a=sc.nextInt(); // enter 1st integer
  b=sc.nextInt(); // enter 2nd integer
  int sum=summation(a,b);   // call function
  System.out.println(sum);  // display message 
 }
    public static int summation(int a,int b){
        //Write your code here
       int s=0;
     s=a+b;         // compute sum 
     return s;  
     //return type "int".
    }

}

 

Window Help
Vehicle.java Arrays.java
Constructor...
* Implement method/function with name 'summation' below.
8
* The function accepts following as parameters.
9
1. a is of type int.
10
* 2. b is of type int.
11
* return int.
12
*/
130
public static void main(String[] args)
14
{
15
Scanner sc-new Scanner(System.in);
int a,b;
16
17
18
a=sc.nextInt(); // enter 1st integer
b=sc.nextInt(); // enter 2nd integer
int sum=summation(a,b); // call function
19
20 System.out.println(sum); // display message
21
}
220
public static int summation (int a,int b){
//Write your code here
23
24
int s=0;
25
// compute sum
26
27
28
29
30 }
31
HelloWorld.java
1 import java.util.*;
2 import java.io.*;
3 import java.math.*;
4 class Outcome {
5
60
7
78
*
s=a+b;
return s;
//return type "int".
}
Constructor...
Method.java
package-info-
Transcribed Image Text:Window Help Vehicle.java Arrays.java Constructor... * Implement method/function with name 'summation' below. 8 * The function accepts following as parameters. 9 1. a is of type int. 10 * 2. b is of type int. 11 * return int. 12 */ 130 public static void main(String[] args) 14 { 15 Scanner sc-new Scanner(System.in); int a,b; 16 17 18 a=sc.nextInt(); // enter 1st integer b=sc.nextInt(); // enter 2nd integer int sum=summation(a,b); // call function 19 20 System.out.println(sum); // display message 21 } 220 public static int summation (int a,int b){ //Write your code here 23 24 int s=0; 25 // compute sum 26 27 28 29 30 } 31 HelloWorld.java 1 import java.util.*; 2 import java.io.*; 3 import java.math.*; 4 class Outcome { 5 60 7 78 * s=a+b; return s; //return type "int". } Constructor... Method.java package-info-
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

Thank you!!! Would you mind telling me briefly what was wrong with the original code?

 

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,