Answer)
Program for printing -10 to 10 counting by 0.5 using for loop:
public class CountingByHalves{
public static void main(String []args){
for(double x=-10.0;x<=10.0;){
System.out.println(x);
x=x+0.5;
}
}
}
Output:
-10.0
-9.5
-9.0
-8.5
-8.0
-7.5
-7.0
-6.5
-6.0
-5.5
-5.0
-4.5
-4.0
-3.5
-3.0
-2.5
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
6.0
6.5
7.0
7.5
8.0
8.5
9.0
9.5
10.0
This is for Java 3. Counting by Halves Write a program called Countingßyllalves. java that uses...
Write a program in Java that performs the Counting Sort algorithm. a) Create the countingSort method. Use the pseudocode shown in the lecture. b) Test your codes by writing a program that uses the following input array: int[] array_A = {6, 0, 2, 0, 1, 3, 4, 6, 1, 3, 2}; c) Your output should display the following versions of the arrays: I. The original input array A II. The counting array C after the counting (lines 4-5 in pseudocode)...
Machine Problem 7: Structures ---- TO BE COMPLETED IN C++ This assignment is to give you practice using one-dimensional arrays and sorting. In competitive diving, each diver makes dives of varying degrees of difficulty. Nine judges score each dive from 0 through 10 in steps of 0.5. The difficulty is a floating-point value between 1.0 and 3.0 that represents how complex the dive is to perform. The total score is obtained by discarding the lowest and highest of the judges’...
Write a Java program to implement Counting Sort and write a driver to test it. Note: use random number generator to generate your input with n = 10, 50, and 100. Verify that the running time is O(n).
I need java code for the following problem.
Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that accepts one integer parameter and returns the value raised to the third power as an integer. o Write a method called randominRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. 2. o Write a method...
Java please Write program that uses a loop to print the powers of 3 from 30 up to and including 39. (30 is 3^0 and 39 is 3^9)
having trouble working excel, please help
Lab Assignment Each student has been assigned a unique data set, and will be required to perform basic statistical analyses on the data. Each exercise should be saved to a new file so one of your first tasks will be to make sufficient copies of your data file, named appropriately. E.g. Grant, Karen Inf Stats Ex1; Grant, Karen Inf Stats Ex2; Grant, Karen Inf Stats Ex3. All data files are taken from real data...
Write a program in Java that converts the following do-while loop block to: for loop Write, compile and run below program segment. Make sure to click on the Output Window to input the number. Evaluate the program. Take notes and comment of below program segments of your observations. int x; Scanner input = new Scanner(System.in); x = input.nextInt(); do{ System.out.printf(“%d\n”, x * 2); x++; } while(x < 100);
Write a simple Java program with the following naming structure: Open Eclipse Create a workspace called hw1 Create a project called hw1 (make sure you select the “Use project folder as root for sources and class files”) Create a class called Hw1 in the hw1 package (make sure you check the box that auto creates the main method). Add a comment to the main that includes your name Write code that demonstrates the use of each of the following basic...
Write a java program that creates a file called numbers.txt that uses the PrintWriter class. Write the odd numbers 1 to 99 into the file. Close the file. Using Scanner, open the numbers.txt file and read in the numbers. Add them all up and print the total. Close the file.
.Need code for my java class !! Write a simple java program that uses loops. You may use ‘WHILE’ or ‘FOR’ or ‘DO-WHILE’ – you decide. The program should use a loop to compute the semester average for up to 5 students. In the loop the user will ask for a student name and their 3 test scores and add them up and divide the total by 3 giving the semester average. You will print out the student name and...