In this lab, you complete a partially written Java program that includes methods that require multiple parameters (arguments). The program prompts the user for two numeric values. Both values should be passed to methods named calculateSum(), calculateDifference(), and calculateProduct(). The methods compute the sum of the two values, the difference between the two values, and the product of the two values. Each method should perform the appropriate computation and display the results. The source code file provided for this lab includes the variable declarations and the input statements. Comments are included in the file to help you write the remainder of the program. My code: import java.util.Scanner; public class Computation {    public static void main(String args[])     {       double value1;       String value1String;       double value2;                       String value2String;        Scanner input = new Scanner(System.in);                 System.out.println("Enter the first numeric value: ");       value1String = input.nextLine();       value1 = Double.parseDouble(value1String);       System.out.println("Enter second numeric value: ");       value2String = input.nextLine();       value2 = Double.parseDouble(value2String);               // Call calculateSum() here       System.out.println(calculateSum(value1,value2));       // Call calculateDifference() here       System.out.println(calculateDifference(value1,value2));       // Call calculateProduct() here       System.out.println(calculateProduct(value1,value2));       System.exit(0);    } // End of main() method.            // Write calculateSum() method here. public static double calculateSum(double a,double b){        return a + b;    }    // Write calculateDifference() method here. public static double calculateDifference(double a,double b){     return a - b;     }    // Write calculateProduct() method here. public static double calculateSum(double a,double b){     return a*b;    } } // End of Computation class.

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter7: Using Methods
Section: Chapter Questions
Problem 3RQ
icon
Related questions
Question

I already written a code but this error keeps on showing up, I don't know what's wrong with it. Programming language used is Java. If my code is messy, please debug it. Thank you.

Problem:

In this lab, you complete a partially written Java program that includes methods that require multiple parameters (arguments). The program prompts the user for two numeric values. Both values should be passed to methods named calculateSum(), calculateDifference(), and calculateProduct(). The methods compute the sum of the two values, the difference between the two values, and the product of the two values. Each method should perform the appropriate computation and display the results. The source code file provided for this lab includes the variable declarations and the input statements. Comments are included in the file to help you write the remainder of the program.

My code:


import java.util.Scanner;

public class Computation
{
   public static void main(String args[]) 
   {
      double value1;
      String value1String;
      double value2;                
      String value2String; 
      Scanner input = new Scanner(System.in);
         
      System.out.println("Enter the first numeric value: ");
      value1String = input.nextLine();
      value1 = Double.parseDouble(value1String);
      System.out.println("Enter second numeric value: ");
      value2String = input.nextLine();
      value2 = Double.parseDouble(value2String); 
      
      // Call calculateSum() here
      System.out.println(calculateSum(value1,value2));
      // Call calculateDifference() here
      System.out.println(calculateDifference(value1,value2));
      // Call calculateProduct() here
      System.out.println(calculateProduct(value1,value2));
      System.exit(0);

   } // End of main() method.
   
   
   // Write calculateSum() method here.
public static double calculateSum(double a,double b){
       return a + b;
   }

   // Write calculateDifference() method here.
public static double calculateDifference(double a,double b){
    return a - b;
   
}
   // Write calculateProduct() method here.
public static double calculateSum(double a,double b){
    return a*b;
  
}


} // End of Computation class.
>- Terminal
+
Computation.java:46: error: method calculateSum(double, double) is
already defined in class Computation
public static double calculateSum(double a, double b){
Computation.java:29: error: cannot find symbol
System.out.println(calculateProduct(valuel,value2));
method calculateProduct(double,double)
symbol:
location: class Computation
2 errors
Error: Could not find or load main class Computation
Transcribed Image Text:>- Terminal + Computation.java:46: error: method calculateSum(double, double) is already defined in class Computation public static double calculateSum(double a, double b){ Computation.java:29: error: cannot find symbol System.out.println(calculateProduct(valuel,value2)); method calculateProduct(double,double) symbol: location: class Computation 2 errors Error: Could not find or load main class Computation
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Function Calling
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,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT