ans 6:
![1 import java.util.*; 2 public class Main 3- { public static void main(String[] args) { Scanner sc=new Scanner(System.in); Sy](http://img.homeworklib.com/questions/3d4e6520-795c-11eb-aa1a-ad4d8eba2846.png?x-oss-process=image/resize,w_560)
output:

code:
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new
Scanner(System.in);
System.out.print("Enter value of
a:");
int a=sc.nextInt(); /*here we take
input of af a*/
while(a<100) /*we do untill
a<100*/
{
System.out.println("Bad"); /*if
condition true than we print this*/
a++;
}
System.out.println("Done"); /*when
it get false than we print this*/
}
}
ans 7:
![Trace table of program myarray[i] 1= 38 1=4 9 1=5 1=6 5 s=s+myarray[i] 10+8=18 18+9=27 27+7=34 34+5=39 ► In the above trace t](http://img.homeworklib.com/questions/3f2f29a0-795c-11eb-96c7-517aa4472322.png?x-oss-process=image/resize,w_560)
final value of s = 39
ans 8:
![ovou ĐWN import java.util.*; 2 public class Main 3- { public static void main(String[] args) { ArrayList<String> mywords = ne](http://img.homeworklib.com/questions/3f8a9250-795c-11eb-a2f7-63dd22b1bb18.png?x-oss-process=image/resize,w_560)
output:

here we get blank output because only one data is in mywords.so,k=1 so 2<1 getting false......
6. From the following flow-chart, write the java code. false a<100 print Done true print Bad...
In Java programming language Please write code for the 6 methods below: Assume that Student class has name, age, gpa, and major, constructor to initialize all data, method toString() to return string reresentation of student objects, getter methods to get age, major, and gpa, setter method to set age to given input, and method isHonors that returns boolean value true for honors students and false otherwise. 1) Write a method that accepts an array of student objects, and n, the...
use java and write in text
a. Rewrite the following code segment using if statements. Assume that grade has been declared as of type char. char grade= 'B';; switch (grade) { case 'A': System.out.println("Excellent"); break case 'B': System.out.println("Good"); default: System.out.println("you can do better”); } - b. write Java code that inputs an integer and prints each of its digit followed by ** e.gif the integer is 1234 then it should print 1**2**3**4 e.g. if the integer is 85 then it...
Please write where its written write your code here!! please use java for the code! please use the given code and I will rate thanks Magic index in an array a[1..n] is defined to be an index such that a[ i ] = i. Given an array of integers, write a recursive method to find the first magic index from left to right. If one exists in the given array, return the index number i, otherwise return -1. Here are...
1) Write a public static method named printArray, that takes two arguments. The first argument is an Array of int and the second argument is a String. The method should print out a list of the values in the array, each separated by the value of the second argument. For example, given the following Array declaration and instantiation: int[] myArray = {1, 22, 333, 400, 5005, 9}; printArray(myArray, ", ") will print out 1, 22, 333, 400, 5005, 9 printArray(myArray,...
*Java* Hi. I need some help with creating generic methods in Java. Write a program GenMethods that has the following generic methods: (1) Write the following method that returns a new ArrayList. The new list contains the nonduplicate (i.e., distinct) elements from the original list. public static ArrayList removeDuplicates(ArrayList list) (2) Write the following method that shuffles an ArrayList. It should do this specifically by swapping two indexes determined by the use of the random class (use Random rand =...
6. (4 points) The following code for insertion sort has been modified to print out the sorted component of the array during the sort. What will be the output of running the main method of the following code? Try to trace by hand and then verify by executing the code public class Insertion ( public static void sort (String[] a) f int n- a.length; for (int i-1; i < n; i++) f for (int j i; j 0; j--) if...
Assignment 06 – Ten Array Methods You must work in alone on this assignment. Do not use any Java language features we have not cover so far in this course. Assignment Objectives After completing this assignment the student should be able to: Declare and instantiate arrays Access array elements by index Use loops and decisions to manipulate arrays and array elements Write methods that manipulate arrays Write methods that take array arguments Write methods...
(Done in Eclipse Java) 1. Given an integer between 1—100 captured from a user, perform the following conditional actions: • If is odd, print Weird • If is even and in the inclusive range of 2 to 5, print Not Weird • If is even and in the inclusive range of 6 to 20, print Weird • If is even and greater than 20, print Not Weird Note: Validate that your algorithm works for all cases. 2. Read an integer...
Need to code the HeapSort Algorithm in java. Most of the code is already done just need to code the "heapify" part of the heapsort algorithm. My heapify code is in bold below called "sink", but when I run it it gives me 2 errors with the string compare part saying: WordCountHeap.java:61: error: cannot find symbol if(l < k && String.Compare(pq[l], pq[n]) < 0) ^ symbol: method Compare(String,String) location: class String Please fix the code and the "heapify"...
this is a while array mystery from java. please help me to write
the code for this question to run it on eclipse !! I want the full
code to run this program !!
Consider the following method: public static void arrayMystery (int[] a) { for (int i = a. length - 1; i >= 1; i--) { if (a[i] > ali - 1] + 10) { ali - 1] = a[i - 1] + 5; Indicate in the right-hand...