
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](http://img.homeworklib.com/questions/1193cb30-8dc7-11eb-8428-69cb0b049b8b.png?x-oss-process=image/resize,w_560)
Can you help me on this programming homework? Can you do same like this? Just do...
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 - 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...
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...
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" + ...
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...
C programming Problem 3 [Set via Hashing] As mentioned in the lecture, a hash table can be used to implement a Set ADT. Let's try to use the template below to implement a Set with double hashing. Here we assume the Set contains names with 3 characters long. Since it is a Set, we do not need to have an explicit value for each key. We will use a token value of 1 if a name belongs to the Set....
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...
C
program
take values to 9 and the second can take values to 12 if (x > 2^3) printf("d", x); Int s-e; 21. LOST) Write a statement that declare an array of doubles with two indices, such that the first index can 22 (LOL) The following code will print out: 23. (L02.) The following code will print out: PART 2 Fill in the banks questions 3 marts x + 5; else x -- 2; char "stri - "abcd"; char str2[]...
1 Problem Description Instructions. You are provided one skeleton program named LCS.java . The source files are available on Canvas in a folder named HW6 . Please modify the skeleton code to solve the following tasks. • Task 1 (100 pts). Implement the lcs length() function as discussed in Lecture 11. • Note: You should not return the double-array b and c as in the pseu- docode. Instead, return the length of the longest common subsequence. • Hint: To get...
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...