Ask Experts Questions for FREE Help !
Ask

I want the java code please

Asked Oct 13, 2011, 04:29 PM — 2 Answers
Write a program that ask from the user how many integers you want to read then reads the set of integers from user, and then finds and prints the sum of even valued and odd valued integers . And also count how many even was entered by user and how many odd were entered by user.

2 Answers
ScottGem's Avatar
ScottGem Posts: 58,014, Reputation: 28115
Computer Expert and Renaissance Man
 
#2

Oct 13, 2011, 04:44 PM


Thank you for asking our help with your homework assignment. However, there are some rules we have for doing so.
Do not simply retype or paste a question from your book or study material

We won't do your homework questions for you. You were given the assignment for you to learn.

If you come up with your own answer or process and post it for us to critique that is acceptable. If you have some SPECIFIC questions that you couldn't find or didn't understand, we may help with that.
But this is your assignment, so show us you have at least attempted to complete it on your own.

Thank you.
Helpful
ronax's Avatar
ronax Posts: 2, Reputation: 10
Junior Member
 
#3

Oct 13, 2011, 05:50 PM
import java.util.Scanner;
public class Q5
{
public static void main(String[]args)
{
Scanner input=new Scanner(System.in);
int a,b,c,d,e,x,i;
int sum=0;
int numEvens = 0;
int numOdds = 0;


System.out.print("How many integer you want to read:");
a=input.nextInt();


System.out.print("Enter 1 integer:");
b=input.nextInt();


System.out.print("Enter 2 integer:");
c=input.nextInt();


System.out.print("Enter 3 integer:");
d=input.nextInt();


System.out.print("Enter 4 integer:");
e=input.nextInt();


System.out.print("Enter 5 integer:");
x=input.nextInt();


System.out.println("Total Even valued integers entered are:");


System.out.println("Total Odd valued integers entered are:");



if(i%2==0)

sum+=i;


{ System.out.println("Sum of even numbers: "+sum);}



{ System.out.println("sum of Odd integer is: "+sum);
}


}
}



{
if (eachValue % 2 == 0 )
numEvens++;
else
numOdds++;
}
System.out.println("There are " + numOdds + " Odd Numbers");
{
if (eachValue % 2 != 0 )
System.out.print(eachValue + " , ");
}
}
}

Helpful

Not your question? Ask your question View similar questions

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Add your answer here.

Remove Text Formatting

Undo
Redo
 
Decrease Size
Increase Size
Bold
Italic
Underline
Align Left
Align Center
Align Right
Ordered List
Unordered List
Decrease Indent
Increase Indent
Insert Email Link
Wrap [QUOTE] tags around selected text
Wrap [CODE] tags around selected text
Wrap [HTML] tags around selected text
Wrap [PHP] tags around selected text
Wrap [YOUTUBE] tags around selected text
Notification Type:



Check out some similar questions!

Calculation in java code [ 4 Answers ]

In my program total of fields is 53.25 but it is giving 53.24999 Why it is happening like that

Java code [ 2 Answers ]

Please give me a simple java code for addition of two numbers here two numbers are accepted From users please give me explanation about each code

Java code [ 2 Answers ]

Please give me a java program for additon of two numbers here nos are accepted from users here I am not confident about java program so please gieve me java code I only understand a hello program so please help me

Java code [ 1 Answers ]

What is difference between argument and parameter element as use in calling routines/coding a method? Can one use them interchangeably for talking/writing purposes?


View more Java questions Search