I need help trying to find a source code to calculate both ofthese series: (a) 1
ID: 3614425 • Letter: I
Question
I need help trying to find a source code to calculate both ofthese series: (a) 1 - 3 + 5 - 7 + ... - ( n - 2) + n (b) m - (m + 2) + ... - ( n - 2) + n For (a), so far I've got this: // method mySumOddNum with one parameter public static int mySummOddNum (int myN) { int localSum; localSum = 0; for (int i = 1; i <= myN; i????) localSum = localSum + i; return localSum; } // end of method mySumOddNum with one parameter For (b): I don't have a clue... I need help trying to find a source code to calculate both ofthese series: (a) 1 - 3 + 5 - 7 + ... - ( n - 2) + n (b) m - (m + 2) + ... - ( n - 2) + n For (a), so far I've got this: // method mySumOddNum with one parameter public static int mySummOddNum (int myN) { int localSum; localSum = 0; for (int i = 1; i <= myN; i????) localSum = localSum + i; return localSum; } // end of method mySumOddNum with one parameter For (b): I don't have a clue...Explanation / Answer
please rate - thanks hopefully should get you started explanation of flip if flip=1 0-1=-1 if flip =-1 0--1=1 so it flips back and forth between add and subtract import java.util.*; public class untitled2 {public static void main(String[] args) {Scanner in=new Scanner(System.in); int n,m,results; System.out.print("Enter a number: "); n=in.nextInt(); System.out.print("Enter a 2nd number, less than the first: "); m=in.nextInt(); System.out.println("The answer to part a is:"+mySummOddNum(n)); System.out.println("The answer to part b is:"+mySummOddm(m,n)); } // method mySumOddNum with one parameter public static int mySummOddNum (int myN) { int localSum,flip; localSum = 0; flip=1; for (int i = 1; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.