Question

Q1. Write a program in Java         a. Create 2 separate arrays, of user defined values,...

Q1. Write a program in Java

        a. Create 2 separate arrays, of user defined values, of same size

        b. Add these 2 arrays.

...........................................................................................................................

Q2. Write a program in java (using loop) input any10 numbers from user and store in an array. Check whether each of array element is positive, negative, zero, odd or even number.

............................................................................................................................

Q3. Write a program in Java to display first 10 natural numbers. Find the sum of only odd numbers.

..............................................................................................................................

Q4. Write a Java program to check if an array of integers contains two specified elements 65 and 77.

Please i need it now very urgent

0 0
Add a comment Improve this question Transcribed image text
Answer #1

3) Code for this is given as :

class Main {

//main function starts here

public static void main(String[] args) {

//variables are declared and initialized

int i,sum=0;

System.out.println("The 1st 10 natural numbers are :");

//loop is used to print the 1st 10 natural numbers

for(i=1;i<=10;i++){

System.out.print(i + " ");

//every odd number on dividing by 2, will give remainder as 1. Then just add those numbers and stored in sum

if(i%2==1){

sum = sum + i;

}

}

//results are printed

System.out.println("\nSum of only odd numbers are : " +sum);

}

}

Output :

Add a comment
Know the answer?
Add Answer to:
Q1. Write a program in Java         a. Create 2 separate arrays, of user defined values,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a Program in C language for: 1. Create a C program to read 7 integers...

    Write a Program in C language for: 1. Create a C program to read 7 integers and store them in an array. Next, the program is to check if the array is symmetric, that is if the first element is equal to the last one, the value of the second one is equal to the value of the last but one, and so on. Since the middle element is not compared with another element, this would not affect the symmetry...

  • java programe Write a program that prompts the user to enter in an integer number representing...

    java programe Write a program that prompts the user to enter in an integer number representing the number of elements in an integer array. Create the array and prompt the user to enter in values for each element using a for loop. When the array is full, display the following: The values in the array on a single line. The array with all of the elements reversed. The values from the array that have even numbered values. The values from...

  • Write a C++ program that simulates a lottery game. Your program should use functions and arrays....

    Write a C++ program that simulates a lottery game. Your program should use functions and arrays. Define two global constants: - ARRAY_SIZE that stores the number of drawn numbers (for example 5) -MAX_RANGE that stores the highest value of the numbers ( for example 9 ) The program will use an array of five integers named lottery, and should generate a random number in the range of 0 through 9 for each element of the array. The user should enter...

  • Write a java program that specifies three parallel one dimensional arrays name length, width, and area....

    Write a java program that specifies three parallel one dimensional arrays name length, width, and area. Each array should be capable of holding a number elements provided by user input. Using a for loop input values for length and width arrays. The entries in the area arrays should be the corresponding values in the length and width arrays (thus, area[i] =   length [i]* width [i]) after data has been entered display the following output: (in Java)

  • Write a program that will create an array of ten integers, allow the user to enter...

    Write a program that will create an array of ten integers, allow the user to enter those integers, and eventually search through the array based on index position: 1. Declare the array. You cannot assign elements to an array until it has first been created. 2. Next, run a for loop so that the user can enter an integer to save in each index position of the array. Since you this array holds ten elements , the index position starts...

  • IN JAVA... Write a program that would create a one-dimensional array of length 7, with user-specified...

    IN JAVA... Write a program that would create a one-dimensional array of length 7, with user-specified values and display the array values. Then search the array for the smallest value and display both the value and its position in the array.

  • Develop a system flowchart and then write a menu-driven C++ program that uses user-defined functions arrays,...

    Develop a system flowchart and then write a menu-driven C++ program that uses user-defined functions arrays, and a random number generator. Upon program execution, the screen will be cleared and the menu shown below will appear at the top of the screen and centered. The menu items are explained below. Help Smallest Quit H or h ( for Help ) option will invoke a function named help() which will display a help screen. The help screen(s) should guide the user...

  • For Java - Write a program that creates an array of 10 integers. Ask the user...

    For Java - Write a program that creates an array of 10 integers. Ask the user to enter the subscript (index) of an element, then displays the element located at that subscript. If the subscript entered is out of bounds (less than 0 or greater than length - 1), display the message "Out of Bounds".

  • JAVA Write a program that prompts the user to enter a file name, then opens the...

    JAVA Write a program that prompts the user to enter a file name, then opens the file in text mode and reads it. The input files are assumed to be in CSV format. The input files contain a list of integers on each line separated by commas. The program should read each line, sort the numbers and print the comma separated list of integers on the console. Each sorted list of integers from the same line should be printed together...

  • Please write a Java program that does the following: Create an array of 100 integers. Store...

    Please write a Java program that does the following: Create an array of 100 integers. Store 100 random integers (between 1 and 100) in the array. Print out the elements of the array. Sort the array in ascending order. Print out the sorted array. Prompt the user to enter a number between 1 and 100. Search the array for that number and then display "Found" or "Not Found" message. Display each number from 1 to 100 and the number of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT