Help with java Please import java.util.*; public class Recursion{ public static void main(String args[]){ Scanner input = new Scanner(System.in); String exp = input.nextLine();...







Help with java Please



import java.util.*;



public class Recursion{


public static void main(String args[]){


Scanner input = new Scanner(System.in);


String exp = input.nextLine();


System.out.println(solver(exp.split(" ")));


}


public static double solver(String[] expression){


double result = 0;


if(expression.length == 3){result = add(Double.parseDouble(expression[0]),Double.parseDouble(expression[2]));}


else if(expression.length == 5){result = add(Double.parseDouble(expression[0]),Double.parseDouble(expression[2]),Double.parseDouble(expression[4]));}


else if(expression.length == 7){result = add(Double.parseDouble(expression[0]),Double.parseDouble(expression[2]),Double.parseDouble(expression[4]),Double.parseDouble(expression[6]));}


else if(expression.length == 9){result = add(Double.parseDouble(expression[0]),Double.parseDouble(expression[2]),Double.parseDouble(expression[4]),Double.parseDouble(expression[6]),Double.parseDouble(expression[8]));}


else if(expression.length == 11){result = add(Double.parseDouble(expression[0]),Double.parseDouble(expression[2]),Double.parseDouble(expression[4]),Double.parseDouble(expression[6]),Double.parseDouble(expression[8]),Double.parseDouble(expression[10]));}


return result;


}


public static double add (double a, double b){return a+b;}


public static double add(double a, double b, double c){return a+b+c;}


public static double add(double a, double b, double c, double d){return a+b+c+d;}


public static double add(double a, double b, double c, double d, double e){return a+b+c+d+e;}


public static double add(double a, double b, double c, double d, double e, double f){return a+b+c+d+e+f;}


}














Output<br>1.0<br>12.8<br>COMPLE AND RN<br>Submit your code by pressing the button<br>below<br>Chek<br>Net<br>

Extracted text: Output 1.0 12.8 COMPLE AND RN Submit your code by pressing the button below Chek Net
Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here