Answer to Question #245315 in Java | JSP | JSF for Ruqqhy

Question #245315

Write a java programme named Adding Numbers.java that uses a method to sum all the integers from 10 to 20 but skipping 15 and 16. Invoke the method within the print command line to print The sum of all integers from 10 to 20 excluding 15 and 16 is 134.


1
Expert's answer
2021-10-01T07:45:36-0400


package numbers;


public class Numbers {
 static int sum(){
      int total = 0;
      for(int i=10; i<=20; i++){
          if(i==15 || i==16){
              continue;
          }
          else{
              total += i;
          }
      }
      return total;
  }
   
    public static void main(String[] args) {
        
        System.out.println("he sum of all integers from 10 to 20 excluding 15 and 16 is: "+sum());
    }
    
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

RICHARD
01.10.21, 17:07

I appreciate your master minded in java, good job guys....keep it up!!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS