correct logic or syntax errors public static void mainString
correct logic or syntax errors
public static void main(String[] args) {
int num = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
for (int i = 0; i < num.length - 1; i++) {
System.out.println(\"The sum is \" + (num(i) + num(i + 1)));
}
}
ArrayList numbers = new ArrayList();
public static void main(String[] args) {
int[] num = { 7, 2, 6, 4, 12, 6, 1, 8, 49, 3 };
int lowest = num[0];
int highest = num[0];
for (int i = 0; i < num.length; i++) {
if (num[i] < lowest) {
lowest = num[i];
} else {
highest = num[i];
}
}
}
public static boolean doesArrayContain(int [] arr, int target) {
boolean found = false;
for (int i = 0; i < arr.length; ++i) {
if (arr[i] == target) {
found = true;
} else {
found = false;
}
}
return found;
}
public static void main(String[] args) {
ArrayList<String> coins = new ArrayList<String>();
coins.add(\"quarter\");
coins.add(\"dime\");
coins.add(\"nickel\");
coins.add(\"penny\");
System.out.println(\"The coins are: \");
for (int i = coins.size() - 1; i > 1; i--) {
System.out.println(coins.get(i) + \" \");
}
}
Rewrite this while loop into a for loop
int ctr = 20;
while (ctr > 0) {
System.out.println(\"The value of ctr is \" + ctr);
ctr = ctr - 2;
}
Rewrite this for loop into a while loop
for (int ctr = 0; ctr < 100; ctr = ctr + 5) {
System.out.println(\"The value of ctr is \" + ctr);
}
The following is a mini-lab that will help you master array constructs. In this mini-lab you will build a test class, the class to test, and a driver class that is a program that can be run. The following is the specification:
We will be modeling a simple gradebook feature using a class called that is based on the mini-lab of the Week 8 assignment. All of the prior specifications remain in place. However, in this mini-lab, you will be adding the following features:
A new class constant (public, static and final) in Assignment called MAX_SCORES that is set to 15.
A new instance variable in Assignment that is an integer array to hold all the scores that are accrued.
The accrueScore() method may now only accrue up to MAX_SCORES total scores. Attempting to add more scores will result in latter scores being ignored.
A getScoreList() accessor method that returns a string holding a comma-separated list of the scores that have been accrued.
A getStdDev() accessor method that returns the standard deviation of all the scores according to the following formula:
SN = sqrt(1/N summation( xi - xbar)^2
Where is the count of scores accrued, is the average score, and
For example, if the scores 120, 100, 130, and 145 have been entered, first calculate the average of the scores as 123.75. Then sum the squares of the differences between each element of the array and the mean: (120-123.75)2 + (100-123.75)2 +(130-123.75)2 +(145-123.75)2 = 1068.75. Finally, divide that number by the count and take the square root: = 16.35.
You will be modifying your Assignment, AssignmentTest, and AssignmentDriver classes
Solution
public static void main(String[] args) {
int[] num = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
for (int i = 0; i < num.length - 1; i++) {
System.out.println(\"The sum is \" + (num[i] + num[i + 1]));
}
}
ArrayList<Integer> coins1 = new ArrayList<Integer>();
public static void main(String[] args) {
int[] num = { 7, 2, 6, 4, 12, 6, 1, 8, 49, 3 };
int lowest = num[0];
int highest = num[0];
for (int i = 1; i < num.length; i++) {
if (num[i] < lowest) {
lowest = num[i];
}
else if(num[i]>highest)
{
highest = num[i];
}
}
}
public static boolean doesArrayContain(int [] arr, int target) {
boolean found = false;
for (int i = 0; i < arr.length; ++i) {
if (arr[i] == target) {
found = true;
break;
}
}
return found;
}
public static void main(String[] args) {
ArrayList<String> coins = new ArrayList<String>();
coins.add(\"quarter\");
coins.add(\"dime\");
coins.add(\"nickel\");
coins.add(\"penny\");
System.out.println(\"The coins are: \");
for (int i = coins.size() - 1; i >= 0; i--) {
System.out.println(coins.get(i) + \" \");
}
}
int ctr = 20;
for(ctr=20;ctr>0;ctr=ctr-2)
System.out.println(\"The value of ctr is \" + ctr);
int ctr = 0;
while(ctr<100)
{
System.out.println(\"The value of ctr is \" + ctr);
ctr = ctr+5;
}
![correct logic or syntax errors public static void main(String[] args) { int num = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; for (int i = 0; i < num.length - 1; i++) correct logic or syntax errors public static void main(String[] args) { int num = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; for (int i = 0; i < num.length - 1; i++)](/WebImages/15/correct-logic-or-syntax-errors-public-static-void-mainstring-1024902-1761530505-0.webp)
![correct logic or syntax errors public static void main(String[] args) { int num = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; for (int i = 0; i < num.length - 1; i++) correct logic or syntax errors public static void main(String[] args) { int num = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; for (int i = 0; i < num.length - 1; i++)](/WebImages/15/correct-logic-or-syntax-errors-public-static-void-mainstring-1024902-1761530505-1.webp)
![correct logic or syntax errors public static void main(String[] args) { int num = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; for (int i = 0; i < num.length - 1; i++) correct logic or syntax errors public static void main(String[] args) { int num = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; for (int i = 0; i < num.length - 1; i++)](/WebImages/15/correct-logic-or-syntax-errors-public-static-void-mainstring-1024902-1761530505-2.webp)
![correct logic or syntax errors public static void main(String[] args) { int num = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; for (int i = 0; i < num.length - 1; i++) correct logic or syntax errors public static void main(String[] args) { int num = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; for (int i = 0; i < num.length - 1; i++)](/WebImages/15/correct-logic-or-syntax-errors-public-static-void-mainstring-1024902-1761530505-3.webp)