Ok my assignment for class is to use the percent mod to calculate the total number of all the numbers and the total number of even numbers only. This should be done by using the user's input of their number.
the % "mod" operator
Input:
The first line of input will be a random list of integers the user will put it.
Output:
Return the total integers in the list and count of even integers.
Sample:
Input Output
3 4 10 12 1 0 6 78 7 #total: 9
#even: 6
...............................................................
this is what I got so far

sandy skiathitis
Greenhorn

Joined: Apr 22, 2011
Posts: 18

posted

0

sandy skiathitis wrote:Ok my assignment for class is to use the percent mod to calculate the total number of all the numbers and the total number of even numbers only. This should be done by using the user's input of their number.
the % "mod" operator
Input:
The first line of input will be a random list of integers the user will put it.
Output:
Return the total integers in the list and count of even integers.
Sample:
Input Output
3 4 10 12 1 0 6 78 7 #total: 9
#even: 6
...............................................................
this is what I got so far

so I redid it ummmmm here is the second version...please help i am getting more lost...

Your for loop appears broken. Take a step back and write down in plain English what the program should do:

1) Read one line from user input
2) While the line has another integer:
2.1) Increase total count of integers
2.2) If the integer is even:
2.2.1) Increase total count of even integers
3) Print total count of integers and total count of even integers

Now solve each step separately. Test your program in between solving steps, and make sure it does what you expect it to do. For instance, print the line after step 1) to make sure it's the same as you've entered.

You seem to have trouble with step 2). Look in the Scanner class for a very useful method.

sandy skiathitis
Greenhorn

Joined: Apr 22, 2011
Posts: 18

posted

0

Stephan van Hulst wrote:Your for loop appears broken. Take a step back and write down in plain English what the program should do:

1) Read one line from user input
2) While the line has another integer:
2.1) Increase total count of integers
2.2) If the integer is even:
2.2.1) Increase total count of even integers
3) Print total count of integers and total count of even integers

Now solve each step separately. Test your program in between solving steps, and make sure it does what you expect it to do. For instance, print the line after step 1) to make sure it's the same as you've entered.

You seem to have trouble with step 2). Look in the Scanner class for a very useful method.

so i would have to use a while statement then an if statement but how to I implement the remainder or percent modulud operator? also would i have to do something specefically so that the program will be able to read more than one input the user puts in??? sorry this is my first programming class and first project of the semester...

I am so confused....the outline helped but I just dont know enough computer language to put it together... I am on the right track? but I have to use percent mod..or the remainder of mod...

sandy skiathitis
Greenhorn

Joined: Apr 22, 2011
Posts: 18

posted

0

sandy skiathitis wrote:

Stephan van Hulst wrote:Here's a skeleton:

I am so confused....the outline helped but I just dont know enough computer language to put it together... I am on the right track? but I have to use percent mod..or the remainder of mod...

this is what I got..I am soooo close...how can I do the total number count...I got lost..can you help???