Question
Can you help me on this programming homework? Can you do same like this? Just do the basic java...for FOR,WHILE and DO-WHILE LOOP.
actor Navigate Search Project Win package csci2e73
I attached the problem... thank you
actor Navigate Search Project Win package csci2e73
0 0
Add a comment Improve this question Transcribed image text
Answer #1

public class repetition
{
   public static void main(String[] args)
   {
       int result = 0;  
      
       for(int i=7; i<=77; i = i+7)
       {
  
           result = result + i;
       }

       System.out.println("sum is= " + result);
  
       System.out.println("\nsum from for method call = " + sum (77));
       System.out.println("\nsum from while method call = " + sum_while (77));
       System.out.println("\nsum from do-while method call = " + sum_doWhile (77));
   }
  
   public static int sum (int n)
   {
       int sum = 0;
      
           for(int i=7; i<=n; i = i+7)
           {
               sum = sum + i;
           }
           return sum;
   }
  
  
   public static int sum_while (int n)
   {
       int sum_while = 0;
       int j = 7;
      
       while(j<=n)
       {
           sum_while = sum_while + j;
           j = j+7;
       }
           return sum_while;
   }
  
  
   public static int sum_doWhile (int n)
   {
       int sum_doWhile = 0;
       int k = 7;
      
       do{
           sum_doWhile = sum_doWhile + k;
           k = k+7;
       }while(k<=n);
       return sum_doWhile;
      
   }
}

EL problems @Javadoc 다 Declaration. Console 23 <terminated> repetition [Java Application] C:\Program Files Java\jre7\bin\java

Add a comment
Know the answer?
Add Answer to:
Can you help me on this programming homework? Can you do same like this? Just do...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I have a java project that I need help trying to finish. I have most of it completed but the issue I am running into is adding numbers with different lengths. Project requirements: . Use a Stack ADT w...

    I have a java project that I need help trying to finish. I have most of it completed but the issue I am running into is adding numbers with different lengths. Project requirements: . Use a Stack ADT with the implementation of your choice (Array or Link), it should not make a difference 2.Read two “integer” numbers from the user. Hint: You don’t need to use an int type when you read, it may be easier to parse the input...

  • I need this code in java. Loops do just what they sound like they should -...

    I need this code in java. Loops do just what they sound like they should - they perform a statement again and again until a condition is fulfilled. For this lab you will be practicing using loops, specifically a for loop. The for loop takes the form of: for(/*variable initialization*/;/*stop condition*/; /*increment*/){ //statements to be done multiple times } Task Write an application that displays every perfect number from 2 through 1,000. A perfect number is one that equals the...

  • Java Programming: Math Quiz

    Starting codes:MathQuiz.javaimport java.util.Scanner;public class MathQuiz {    private final int NUMBER_OF_QUESTIONS = 10;    private final MathQuestion[] questions = new MathQuestion[NUMBER_OF_QUESTIONS];    private final int[] userAnswers = new int[NUMBER_OF_QUESTIONS];    public static void main(String[] args) {        MathQuiz app = new MathQuiz();        System.out.println(app.welcomeAndInstructions());        app.createQuiz();        app.administerQuiz();        app.gradeQuiz();    }    private String welcomeAndInstructions() {        return "Welcome to Math Quiz!\n" +         ...

  • package homework; import java.util.Arrays; import stdlib.*; /** CSC300Homework4 version 1.0 * *    * * Find...

    package homework; import java.util.Arrays; import stdlib.*; /** CSC300Homework4 version 1.0 * *    * * Find the 3 Sections marked TODO: * * TODO #1: SumOddsRecursive * TODO #2: ReverseArray * TODO #3: MergeArrays * * You must not add static variables. You MAY add static functions. * * It is okay to add functions, such as * * <pre> * public static double sumOfOddsHelper (double[] list, int i) { * </pre> * * but it is NOT okay to...

  • java question, my questions are in the following codes with comments, just answer next or under...

    java question, my questions are in the following codes with comments, just answer next or under it thanks! theres only few, so no worry. import java.security.SecureRandom; public class clsTestRand {    public static void main(String[] args) {        // TODO Auto-generated method stub        //int num1, num2, num3, num4, num5, num6;        int num1 = 0;        int num2 = 0;        int num3 = 0;        int num4 = 0;        int...

  • In java. You are provided an abstract class called MyAbstract. You can only modify the writeFile...

    In java. You are provided an abstract class called MyAbstract. You can only modify the writeFile () class. You are provided another class called Finally you are provided the file you must read from in the MyAbstract class. You will need to extend MyAbstract to MyTestClass. You should have the following outputs. The content of myData employee avg salary number of employees File that was created in myFile() Everything I was provided is listed already. l. Servers ary 1 35...

  • Change the factorial method to return a BigInteger. You can leave the parameter value alone (ie,...

    Change the factorial method to return a BigInteger. You can leave the parameter value alone (ie, the parameter will remain an integer). You'll need to modify the method to use BigInteger objects and instance methods. Hint: remember that you can easily form Strings from numerical values by concatenating the numerical value with the empty String "". For Example: String s = 5 + ""; •What happens when you rerun your loop in main? Do you get the correct answers? import...

  • This looks long but it is easy just having some trouble please help out thank you....

    This looks long but it is easy just having some trouble please help out thank you. Find and fix all syntax and semantic errors which prevent the program from compiling. Find and fix all logical errors which cause the program to crash and/or produce unexpected results. In addition to making sure the code compiles, we have one final method which we need to complete. There is a method in the code, printAll, which is responsible for printing out the entirety...

  • Hi, can someone please help me implement the transpose, multiply(Matrix b), multiply(Matrix m, int threads), and...

    Hi, can someone please help me implement the transpose, multiply(Matrix b), multiply(Matrix m, int threads), and equals(Object in) methods? (This is Java) I really need help so please don't just refund the question. public class Matrix {1 public int[] [] matrix; 1 int[] [] trans; 1 public int x, y; 1 private boolean transposed; 1 1 public Matrix(int x, int y){1 matrix = new int[x][y1;1 this.x = x; this.y = y; 1 } 1 9 /*1 * This method takes...

  • I need this program converted to c++ Please help if you can import java.util.*; // Add...

    I need this program converted to c++ Please help if you can import java.util.*; // Add two arrays of the same size (size) // Each array is a representation of a natural number // The returned array will have the size of (size + 1) elements public class Fibonacci { private static String arrToString(int[] arr) {           String s = "";           for (int i = 0; i < arr.length; i++) {               s = s + arr[i];           }...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT