package HomeworkLib;
import java.util.Arrays;
import java.util.Scanner;
public class Q1 {
public static void main(String[] args) {
// TODO Auto-generated method
stub
//if array size exceeds by 40 enter
the desired amount in place of 40 in the following line
int[] arr = new int[40];
Scanner sc = new
Scanner(System.in);
int j = 0;
int count = 0;
int x = 1;
//taking input and
stopping when user enters 0
while (x != 0) {
x =
sc.nextInt();
arr[j] = x;
j++;
count++;
}
//printing the
array
for (int i = 0; i <
count; i++) {
System.out.println("Element at index " + i + " : "+ arr[i]);
}
//count of odd
numbers
int odd = 0;
int even = 0;
for (int k = 0; k <
count; k++) {
if
(arr[k]%2 != 0) {
odd++;
}
else
{
continue;
}
}
//greatest even
number
for (int i = 0; i <
count; i++) {
if
(arr[i]%2 == 0) {
if (even<arr[i]) {
even = arr[i];
System.out.println("even"+even);
}
}
}
//sum of positive
integers
int total = 0;
for (int i = 0; i <
count; i++) {
if (arr[i]
> 0) {
total += arr[i];
System.out.println("total "+total);
}
}
//minimum integer
Arrays.sort(arr);
int min = arr[0];
System.out.println("The
minimum integer is " + min);
System.out.println("The
count of odd integer in the sequence is " + odd);
System.out.println("The
largest even integer in the sequence is " + even);
System.out.println("The
sum of positive integers is " + total);
}
}
What this Assignment Is About: Review on Java I topics, such as primitive data types, basic...
Arizona State University - CSE205 Assignment #9 Due Date Friday, March April 3rd, 5:30pm Important: This is an individual assignment. Please do not collaborate. No late assignment will be accepted. Make sure that you write every line of your code. Using code written by someone else will be considered a violation of the academic integrity and will result in a report to the Dean's office. It must be submitted on-line (Course website). Go to "GradeScope" tab on Canvas -> CSE205...
Assignment #9 will be the construction of a program that reads in a sequence of integers from standard input until 0 is read, and store them in an array (including 0). This is done using iteration (choose one of for, while, or do while loop). You may assume that there will not be more than 100 numbers. Then compute the minimum number, compute the largest number among the numbers that are divisible by 2, count even numbers, and compute the...
(Java Programmin): Sum() and max() in ArrayList a. Write a method that returns the maximum value in an ArrayList of integers. The method returns null if the list is null or the list size is 0. public static Integer max(ArrayList<Integer> list) b. Write a method that returns the sum of all numbers in an ArrayList: public static Integer sum(ArrayList<Integer> list) c. Write a test program that prompts the user to enter a sequence of numbers ending with 0, and invokes...
DESCRIPTION: The range of integers that can be represented in Java using a primitive data type is only from-263 to 263-1. What if we need to manipulate integer values beyond this range? In this assignment you will write a HugeInteger class which is able to represent arbitrar- ily large integer numbers. This class must implement arithmetic operations on integers such as addition, subtraction, multiplication, division and comparison. You have to implement this class without using Java predefined classes, unless specified...
I'm in my first java class at school and really need some help. I've looked online for different programs for the same assignment I'm doing now, and none of them seemto work. Here is the assignment:Write a program that reads integers, finds the largest of them, and counts its occurrences. Assume that the input ends with number 0. Suppose that you entered 3 5 2 55 5 0; the program finds that the largest is 5 and the occurrence count...
This Java program reads an integer from a keyboard and prints it out with other comments. Modify the comments at the top of the program to reflect your personal information. Submit Assignment1.java for Assignment #1 using Gradescope->Assignemnt1 on canvas.asu.edu site. You will see that the program has a problem with our submission. Your program is tested with 4 testcases (4 sets of input and output files). In order to pass all test cases, your program needs to produce the same...
In this lab, you complete a partially written Java program that includes two methods that require a single parameter. The program continuously prompts the user for an integer until the user enters 0. The program then passes the value to a method that computes the sum of all the whole numbers from 1 up to and including the entered number. Next, the program passes the value to another method that computes the product of all the whole numbers up to...
In this lab, you complete a partially written Java program that includes two methods that require a single parameter. The program continuously prompts the user for an integer until the user enters 0. The program then passes the value to a method that computes the sum of all the whole numbers from 1 up to and including the entered number. Next, the program passes the value to another method that computes the product of all the whole numbers up to...
Count Occurrences in Seven Integers Using Java Single Dimension Arrays In this assignment, you will design and code a Java console application that reads in seven integer values and prints out the number of occurrences of each value. The application uses the Java single dimension array construct to implement its functionality. Your program output should look like the sample output provided in the "Count Occurrences in Seven Integers Using Java Single Dimension Arrays Instructions" course file resource. Full instructions for...
C++ assignment Write a program that reads a sequence of integers and prints the following: 1. The number of odd and even numbers of inputs Use a sentinel value to signal the end of inputs. If the sentinel value is the first you enter, give a message “NO input is entered!”. Input Validation: Do not accept a negative number.